Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to display records as follow:

sr no Age Distribution
0 0 254
1 1 125
2 2 45
3 3 47
4 4 24

this is the query i am using, but it is not displaying in series, its series is 1,10,100,2,20,21,22,23

SELECT Age,COUNT(PID)AS [Age wise Distribution]
FROM [Main Data]GROUP BY Age ORDER BY Age asc
Posted

1 solution

What is the datatype of Age?
I guess you have assigned it as nvarchar. Make it integer.
According to nvarchar datatype, you are getting correct result.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900