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


Please Help Members By Posting Answers For Below Questions

Differentiate between a local and a global temporary table?

631


What is best institute to Learn DotNET And SQL in chennai?

1777


Name few of the dcl commands in sql?

637


What is collation sensitivity?

634


What is a partition function in sql server?

615






How and why use sql server?

632


What is acid mean in sql server?

657


What does asynchronous call backs means?

696


What samples and sample databases are provided by microsoft?

671


What is table value parameters (tvp)?

669


Can a stored procedure call itself or recursive stored procedure? How many levels sp nesting is possible?

602


What is the contrast between sql and pl/sql?

696


What is the difference between drop table and truncate table?

566


What is a data source file?

580


How to count duplicated values in a column in ms sql server?

609