I have a table that contains rows of data for clinics. Basically each row has the clinicid and then a load of data regarding performance.
There is also a row where the clinicid is -1 (not a valid clinic) and this holds the summarised data for the whole table.
If I want to select a single clinics data, and the summarized data what would the general syntax be?
Give clinicid of 10 I am looking for:
10, clinic specific data, -1, summerised data
Is the query something like the example below, or is there a better syntax
Given that the column names are clinicid, data1, data2, data3 etc.
@clinicid as ClinicId
Case clinicid = @clinicid then data1 else null end as clinicData1,
Case clinicid = @clinicid then data2 else null end as clinicData2,
Case clinicid = @clinicid then data3 else null end as clinicData3,
-1 as Summary,
Case clinicid = -1 then data1 else null end as SummaryData1,
Case clinicid = -1 then data2 else null end as SummaryData1,
Case clinicid = -1 then data3 else null end as SummaryData1