Skip to content
Advertisement

Counting occurrences in SQL

I have following table structure:

I want to get the count of students in one school code and display the count. I can do a row_number and get the number of rows in this way:

the output would be:

I am not able to write the sql code to produce the last column (i.e Total_Count). Can you please tell me how to do it.

Advertisement

Answer

You want the count() window function:

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