I have a student marks table with schema as given below:
Student
--------
SNO
Marks
I want to produce a result something as this:
MarksRange Count
---------- ------
0 10
10 2
20 43
: :
100 2
The above results shows that there are:
- 10 students who got a score zero,
- 2 students how got a score between 1 to 10,
- 43 from 11-20
- and so on.
Could anyone please let me know how to write a query which produces this result?
try this:
OUTPUT:
if you are not on SQL Server 2005+ you need to replace the CTE with a Numbers table. and use a query like: