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 types of Joins are possible with Sql Server?
Distinguish between commit and rollback?
What is exporting and importing utility?
What is a field in a table?
What is primary key index?
What is collation sensitivity?
What is a self join in sql server?
what is a transaction and what are acid properties? : Sql server database administration
Do you know the capabilities of cursors?
Write a SQL query in order to merge two different columns into single column?
What are the advantages of the mirroring?
How do you identify a foreign key?
What are differences in between sql server 2012 and sql server 2016?
What is difference between primary key and foreign key?
What is the boxing and unboxing concept in .net?