Skip to content
Advertisement

MS SQL query to list count by status

I want to achieved the result below. I want to list all records having a status of “For Approval” together with this condition:

For example for Username ‘Leo’

Then sum all the status having “For Approval” which is the checker is ‘Leo’ with the condition above

Advertisement

Answer

I think this is what you are after; if its not i have created tables and data inserts which will help whoever gives you the final solution. I think coalesce is the thing you are looking for you; using the status 1,2,3 columns you can work backwards to find the current user in one pass.

It currently returns

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement