I have the following query where I am trying to eliminate the NULL record. How can I do this? My query:
select AttendedSchoolLast3Months = case when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'BC349A1E-65A1-4497-A38A-116C83B2028F' then 2 --No when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'A529C643-60A7-4D79-AC67-1A8F70791934' then 1 --Yes end From [evolv_cs].[dbo].[test_header] [test_header_rv] WITH (NOLOCK) CROSS APPLY [dbo].[fn_getTestSetupFormDetails](null, [test_header_rv].[test_setup_header_id]) AS [test_header] CROSS APPLY [dbo].[fn_getTestSetupFormDetails]([test_header].[test_setup_details_id], null) AS [test_details] JOIN [evolv_reports].[dbo].[test_details_answers_expanded_view] d WITH (NOLOCK) ON [test_header_rv].[test_header_id] = d.[test_header_id] AND [test_details].[test_setup_details_id] = d.[test_setup_details_id] join [user_defined_lut_rv] udl1 with(nolock) on udl1.[user_defined_lut_id] = d.picklist_value join people_rv p (nolock) on d.people_id = p.people_id where d.actual_date between '9/1/13' and '9/30/13' and d.people_id = '7A9ACEE4-ABD5-4905-A54E-659A81048A1A'
And the result currently is:
AttendedSchoolLast3Months 1 NULL
When I ran this query:
select distinct --attendedschoollast3months d.* From [evolv_cs].[dbo].[test_header] [test_header_rv] WITH (NOLOCK) CROSS APPLY [dbo].[fn_getTestSetupFormDetails](null, [test_header_rv].[test_setup_header_id]) AS [test_header] CROSS APPLY [dbo].[fn_getTestSetupFormDetails]([test_header].[test_setup_details_id], null) AS [test_details] JOIN [evolv_reports].[dbo].[test_details_answers_expanded_view] d WITH (NOLOCK) ON [test_header_rv].[test_header_id] = d.[test_header_id] AND [test_details].[test_setup_details_id] = d.[test_setup_details_id] join [user_defined_lut_rv] udl1 with(nolock) on udl1.[user_defined_lut_id] = d.picklist_value --join [education_level] e (nolock) on e.[EducationLevel] = udl1.[description] join people_rv p (nolock) on d.people_id = p.people_id where d.actual_date between '9/1/13' and '9/30/13' and d.people_id = '7A9ACEE4-ABD5-4905-A54E-659A81048A1A'
I get this:
event_log_id people_id group_profile_id actual_date test_header_id test_setup_details_id test_domains_info_id question_caption question_code test_details_answers_id update_log_id test_details_id numeric_value scrnval_id picklist_value remarks narrative test_setup_details_answers_id is_checked date_value details_type_code test_setup_answers_caption test_setup_answers_order test_setup_answers_value output_code answers_category_id answers_category answers_category_code 24E8F88F-9648-4714-9394-D5A3F642C0F0 7A9ACEE4-ABD5-4905-A54E-659A81048A1A NULL 2013-09-26 17:00:00.000 24E8F88F-9648-4714-9394-D5A3F642C0F0 67CDCF44-6308-4E15-8543-3C85DE4C6D4D NULL Attended school in the last 3 months NULL 1BB75044-A65C-4464-ADB9-0CA991019907 7CDD1A4F-41F4-403C-A85E-7FF51B761FF0 3F04BBFF-8DE9-4283-842F-E53A536E3E46 NULL AA5639E4-E60C-473F-9B72-354472C11F5B A529C643-60A7-4D79-AC67-1A8F70791934 NULL NULL 5979600C-B4E6-42DF-BF45-8AFF15ACDD7D 0 NULL PICKLIST Click here for list 1 NULL NULL NULL NULL NULL 24E8F88F-9648-4714-9394-D5A3F642C0F0 7A9ACEE4-ABD5-4905-A54E-659A81048A1A NULL 2013-09-26 17:00:00.000 24E8F88F-9648-4714-9394-D5A3F642C0F0 EBDFBCA5-6E57-4907-9DEF-A1E118F3AB2D NULL Highest grade completed NULL 8F7F4644-4E67-4821-B0FC-A192389F994D 7CDD1A4F-41F4-403C-A85E-7FF51B761FF0 F6C59E67-EC74-4F0C-8EE8-AB372F22255D NULL 4536DD06-871D-4FA7-BA8A-552DB2CA59BC D77F0CAB-505E-4838-AECE-01BAAE8B8EB2 NULL NULL E7C9ECB7-7B40-4115-A6DB-BC752116D68D 0 NULL PICKLIST Click here for list 1 NULL NULL NULL NULL NULL
Ryan D