sql server - Return first row within CASE statement -
i have case statement within select returning many values, want first value since i'm doing count.
select distinct atm.ticketid ,count(case when ((atm.priorityid='e' or atm.priorityid='u') , max(atq.questionid) 1 end)) [a] .....
for each 'e' , 'u' value, there many questionid's (joined table). need 1 questionid each e or u.
i'm having difficulty nested aggregates.
move priorityid clause
select atm.ticketid, atm.priorityid, max(atq.questionid) atm inner join atq on {some criteria} atm.priorityid = 'e'or atm.priorityid = 'u' group atm.ticketid, atm.priorityid
Comments
Post a Comment