• Minimum Value Query Problem (Access 97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Minimum Value Query Problem (Access 97)

    Author
    Topic
    #360253

    I have two tables, one with patient data (patient database) and the other with notes written about the patient (note database). There can be more than one note record for each patient. Patient and note records are linked by a unique case number. Each record in the note database has a sequence number assigned to designate when the note was written and may or may not have information about use of a consultant.

    I want to display the sequence number (plus some other fields) of the note record that has the first consultant used. I never know in which note record the use of a consultant will be charted. It could be the 1st, the 3rd or the 6th. Different consultants can be in different note records on a given patient, but I am only interested in the first one used. I

    have designed a select query that gives me the case number and sequence number, but it returns all of the note records for each patient where any consultant was used. (There is a specific list of consultants available.) How do I limit the query to give me only the note records with the lowest sequence number (e.g., the first consultant used) for each patient?

    I plan on using this in an update query to fill in missing information in the patient database on what the first consultant use was for each patient.

    Thank you for any replies. Hope this makes sense!

    Jim confused

    Viewing 0 reply threads
    Author
    Replies
    • #542089

      Change your query to a “Totals” query (click the button that looks sort of like an “E”, it’s actually the greek letter known as “sigma”). Now all of your fields should show “Group By” in the total line. Change each field except the case number field, to “First”. Sort the sequence number field “Ascending”. Now put “Is Not Null” as criteria for the consultant(name?) field. This will now only show the first record (based on sequence number) for each patient that has a consultant. chatter

      • #542112

        Thanks for putting me on the right track. Actually, I got some really funky results using the “First” in the total field. If there was more than one note record with a consultant in it, it would return the sequence number for the last record, not the first. Changing the sort order or the Total to “Last” still gave wrong results. But only sometimes. Some records were correct, some were wrong. I can’t figure that one out. confused

        When I changed the sequence number field to “Min” I got the right result.

        Thanks for your help. cheers

        Jim

    Viewing 0 reply threads
    Reply To: Minimum Value Query Problem (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: