scottaherbst
Technical User
Hi I posted about this about a week ago and the responses I got almost has it working. Here's the original post updated with a couple of things I don't think I was 100% clear on.
I am working with a client database. I'm pulling from 2 tables. The first is service_records and that gives me the client_id and service_number. I've got it joined (left-inner) to the assessment_table on client_id and service_number so it returns the date_of_assessment.
What this returns is any instance where there is a service number and the date_of_assessment (if there is any). If there wasn't an assessment given at all, it returns the service_number with a Null value for date_of_assessment. If more than one assessment was given for that service_number, it returns one line for each assessment given. I've also got a formula field that calculates the days since the assessment and another that takes that result and categorizes that record into "0-90 days", "91-180", "181 days +", and "no assessment". Here's an example minus the formula fields:
Client_ID Service_Number Date_of_assessment Location
1310 12 Detroit
1311 6 4/1/2007 Hell
1311 6 1/2/2007 Hell
1311 6 8/15/2006 Hell
1311 13 Hell
1311 14 Hell
I then group by client_id and have the most recent assessment given, the days since that assessment, and the category in the header. Ultimately, all I'm really interested in is the last assessment.
(The feedback I got had me write the following command-line:
SELECT service_records.client_id, service_records.location, service_records.service_number, assessment_table.date_of_assessment
FROM SYSTEM.service_records service_records
LEFT OUTER JOIN SYSTEM.assessment_table assessment_table ON ((service_records.client_id = assessment_table.client_id) AND (service_records.service_number = assessment_table.service_number))
WHERE(assessment_table.date_of_assessment IS NULL or (assessment_table.date_of_assessment = (SELECT MAX(A.date_of_assessment) FROM SYSTEM.assessment_table A, service_records B WHERE B.client_id = assessment_table.client_id AND A.client_id = B.client_id AND A.service_number = b.service_number)))
ORDER BY service_records.cleint_id
What this returns are data that look like this:
Client_ID Service_Number Date_of_assessment Location
1310 12 Detroit
1311 6 4/1/2007 Hell
1311 13 Hell
1311 14 Hell
What I want are data that look like this:
1310 12 Detroit
1311 6 4/1/2007 Hell
So - basically, for some services, clients are given an assessmnet and for others they aren't and what I've got now gives me one line for each service they received. I'm only interested, however, in knowing if they were given an assessment at all and, if not, having the report return a line with a null value for the assessment. Any ideas. Obviously I'm stumped.
I am working with a client database. I'm pulling from 2 tables. The first is service_records and that gives me the client_id and service_number. I've got it joined (left-inner) to the assessment_table on client_id and service_number so it returns the date_of_assessment.
What this returns is any instance where there is a service number and the date_of_assessment (if there is any). If there wasn't an assessment given at all, it returns the service_number with a Null value for date_of_assessment. If more than one assessment was given for that service_number, it returns one line for each assessment given. I've also got a formula field that calculates the days since the assessment and another that takes that result and categorizes that record into "0-90 days", "91-180", "181 days +", and "no assessment". Here's an example minus the formula fields:
Client_ID Service_Number Date_of_assessment Location
1310 12 Detroit
1311 6 4/1/2007 Hell
1311 6 1/2/2007 Hell
1311 6 8/15/2006 Hell
1311 13 Hell
1311 14 Hell
I then group by client_id and have the most recent assessment given, the days since that assessment, and the category in the header. Ultimately, all I'm really interested in is the last assessment.
(The feedback I got had me write the following command-line:
SELECT service_records.client_id, service_records.location, service_records.service_number, assessment_table.date_of_assessment
FROM SYSTEM.service_records service_records
LEFT OUTER JOIN SYSTEM.assessment_table assessment_table ON ((service_records.client_id = assessment_table.client_id) AND (service_records.service_number = assessment_table.service_number))
WHERE(assessment_table.date_of_assessment IS NULL or (assessment_table.date_of_assessment = (SELECT MAX(A.date_of_assessment) FROM SYSTEM.assessment_table A, service_records B WHERE B.client_id = assessment_table.client_id AND A.client_id = B.client_id AND A.service_number = b.service_number)))
ORDER BY service_records.cleint_id
What this returns are data that look like this:
Client_ID Service_Number Date_of_assessment Location
1310 12 Detroit
1311 6 4/1/2007 Hell
1311 13 Hell
1311 14 Hell
What I want are data that look like this:
1310 12 Detroit
1311 6 4/1/2007 Hell
So - basically, for some services, clients are given an assessmnet and for others they aren't and what I've got now gives me one line for each service they received. I'm only interested, however, in knowing if they were given an assessment at all and, if not, having the report return a line with a null value for the assessment. Any ideas. Obviously I'm stumped.