I am learning how to use Group By in SQL Server and I am trying to write a Query that would let me get all the information from Alumns in a table in numbers.
My table is like the following:
Name | Alumn_ID | Course | Credits | Passed Peter 1 Math 2 YES John 2 Math 3 YES Thomas 3 Math 0 NO Peter 1 English 3 YES Thomas 2 English 2 YES John 3 English 0 NO The result I want is the following one:
Alumn | Total_Credits | Courses | Passed | Not_Passed Peter 5 2 2 0 John 5 2 2 0 Thomas 0 2 0 2 I know that I have to use Group By and COUNT but I'm stuck since I'm a beginner, I really don't know how can I separate Passed and Not_Passed in the result from the PASSED column in the table, thanks in advance
GROUP BY. You should show what you have attempted.sum(case when Passed = 'YES' then 1 else 0 end)