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 / ramadass

select classname,count(*) from students group by
classname

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is INSTEAD OF trigger directly applicable to Table ?

738


What is it unwise to create wide clustered index keys?

751


What are the components of dbms?

718


You want to generate a report that is formatted as a chart. Can you use the report wizard to create such a report?

105


Which Model uses the SET concept

749


How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?

769


You have to store user responses of ‘yes’ and ‘no’ what kind of data type is best suited for this task?

709


Explain cross join or cartesian product in sql?

699


What is the importance of a recovery model?

774


How do I port a number to sql server?

704


what is a major difference between sql server 6.5 and 7.0 platform wise? : Sql server database administration

663


How does stuff differ from the replace function?

739


What is RAID? What are the different types of RAID configurations?

806


Why we use functions in sql server?

721


What is a trace frag?

824