PDA

View Full Version : some SQL query help?


ABC123

christappan
10-06-2010, 12:40 PM
I've got an application in which contact notes are entered by our case managers with various types of data, including the Individual's ID to whom it's related, the contact date and a code for contact type (TC-Telephone Call, HV-Home Visit, OV-Other Visit, etc.).

I need to build a SQL query/view that will show, for each case number, the last several (let's say 3) notes that had particular codes selected.

The final product would show, in one grid, the Individual's ID and last 5 Dates for the particular codes. I know this isn't making sense, so here's the visual:


Ind ID |Last HV |2 Ago HV |3 Ago HV |Last OV |2 Ago OV |3 Ago OV


I've actually been able to piecemeal queries and views together to produce this, but as we add more contact note records, the queries are highly inefficient.

I'm not educated or experienced in database design, so I know there's ways to do it, but this one's way over my head--can anyone offer suggestions? Thanks in advance.

jorgecardenas1
10-31-2010, 05:18 PM
Perhaps if you upload your database I may be able to suggest something.