Interviews1 answer
Interview Questions.One of the Interview I have faced I was give a query to write,here is the table Id Value 1 10 1 0 2 12 2 12 3 0 4 0 I was asked to find the total number of consumed and unconsumed ids,following is the output table Id Consumed Unconsumed 1 1 1 2 2 0 3 0 1 4 0 1 As we can see consider Id 1 in the output tab
1 Answer
Query
Select Id,Count(Case when Value=0 then 1 else null end) Unconsumed,Count(Case when value > 0 then 1 else null end)Consumed from table1 group by Id
Hope that this query helps someone.
Aniket NarvankarPosted Sep 17, 2015, 8:05 PM EDT

