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 are the steps to process a single select statement?

516


Why you need indexing? Where that is stored and what you mean by schema object? For what purpose we are using view?

498


What is 1nf 2nf?

556


What is the contrast between sql and mysql?

594


How to execute a stored procedure in ms sql server?

554






How to retrieve field values using mssql_result()?

632


Why should we go for stored procedures? Why not direct queries?

574


What are the different types of sql server replication? : sql server replication

630


What is the most common type of join?

532


State a few properties of relational databases?

665


What are the restrictions while creating batches in sql server?

587


What are the limitations/drawbacks or ssrs 2008 r2?

86


can you implement data mining in SSRS?

113


how to determine the service pack currently installed on sql server? : Sql server database administration

567


What are the disadvantages of indexes?

538