Is there a way to group by a case statement in a SQL Query?
i have a code, will post the last part.
group by
case when @pa_id is NULL then
( pct.patient_assignment_id, pat.patient_id,pat.lname,pat.fname,
pct.clinician_id,pat.patient_id,sta.lname,sta.fname )
else 0
end
is that possible? or what is the way to get the needed results? i want it
to group by the given values if the parameter @pa_id is NUll and if it is
not Null, i want it to be grouped by the values from a CTE, which has a
name CTE
No comments:
Post a Comment