Aniket Narvankar
Interview Questions.One of the Interview I have faced I was give a query to write,here is the tableId Value 1 10 1 0 2 12 2 12 3 0 4 0I was asked to find the total number of consumed and unconsumed ids,following is the output tableId Consumed Unconsumed 1 1 1 2 2 0 3 0 1 4 0 1 As we can see consider Id 1 in the output table it has value 1 for consumed column and 1 for unconsumed column,because total number of Ids with value 1 are 2 and one id with value 1 has value greater than 0 and second one has value equal to 0 in the input table.so the conditon is consumed ids are ids whose value is greater than 0 and unconsumed ids are ids whose value is equal to zero.i was asked to write query to generate the following output,I have found many difficulties and was not able to solve during the interview.the interviewer gav
By Aniket Narvankar in SQL Server on Sep 18 2015
  • Aniket Narvankar
    Sep, 2015 18

    QuerySelect 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 IdHope that this query helps someone.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS