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

What is the syntax to execute the sys.dm_db_missing_index_details?

744


What are the 3 types of schema?

780


What is fill factor and pad index?

746


What is function of CUBE ?

758


Can we insert data into view sql server?

716






What are partitioned views?

743


How to enter binary string literals in ms sql server?

820


Different types of keys in SQL?

821


explain what is raid and what are different types of raid configurations? : Sql server database administration

727


What is sql server used for?

727


how many clustered indexes can be created on a table? : Sql server database administration

774


What are actions, how many types of actions are there, explain with example? : sql server analysis services, ssas

736


What is the native system stored procedure to execute a command against all databases?

717


Why I am getting this error when renaming a database in ms sql server?

724


How to create a store procedure with encryption?

701