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 / samba shiva reddy . m
select 'No of students in class '+ CONVERT(VARCHAR,ClassName)+' : '+ convert(varchar,Count(studname)) from students
group by
classname order by classname
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What are the authentication modes in sql server? How can it be changed?
Is it important for a database administrator to understand the operating system and file access?
Is ssrs support other database except ms sql server?
Define candidate key, alternate key, and composite key.
Explain how many normalization forms?
What are the difference between data mart and data warehouse? : sql server analysis services, ssas
What is an execution plan? When would you use it?
what kind of lan types do you know? : Sql server database administration
How do I shrink an ldf file?
What are horizontal and vertical scaling?
How to set the current database in ms sql server?
What is the difference between primary key and unique constraints?
What is the default server name for sql server?
How much does sql server 2016 cost?
How do I start and stop sql server?