i have table students with fields classname,studname
select * from students
classname studname
1 xxxxx
1 yyyy
1 zzzz
2 qqqq
2 tttt
3 dsds
3 www
i want the output should be
No of students in class 1 : 3
No of students in class 2 : 2
No of students in class 3 : 2
Answer Posted / soorai ganesh
SELECT 'No of students in class '+ CONVERT
(VARCHAR,ClassName)+' : '+CONVERT(VARCHAR, COUNT(*)) FROM
students GROUP BY classname
Is This Answer Correct ? | 21 Yes | 0 No |
Post New Answer View All Answers
Why use stored procedures in sql server?
What do you mean by cardinality?
Does partitioning ssd reduce performance?
what information is maintained within the msdb database? : Sql server administration
Will count(column) include columns with null values in its count?
How do indexes help, types?
Can the query output be sorted by multiple columns in ms sql server?
What is ems sql management studio? : sql server management studio
How to view the error log for any specific instance? : sql server database administration
What are locks in sql?
What is a view and what are its advantages?
How you can get a list of all the table constraints in a database?
Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?
What are the filtered indexes?
What are the differences between decimal and float in ms sql server?