After merging several tables, I was able to get the desired output for one day, as shown below:
I select rows from the temporary table. Well, these lines are only for one day, and if I give the date range in the report, my report output should be similar
Surname and followed by column names with dates from the date range, as follows:
The temporary table from which I choose does not have any
date In this column, I populate this temporary table from various table links based on the date range.
SELECT last name, CASE IF EXISTS (SELECT col1 FROM @CT as CT with CT.col1 = # Temp3.id) THEN & # 39; 1 & # 39; IF EXISTS (SELECT col1 FROM @CE as CE with CE.col1 = # Temp3.id) THEN (SELECT CE.reason of @CE as CE with CE.col1 = # Temp3.id) IF EXISTS (SELECT ID FROM @De as DE with DE.col1 = # Temp3.id) THEN & # 39; D & # 39; ELSE & # 39; 1 & # 39; END as one FROM # temp3;
Any help would be appreciated.