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

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

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What number aggregate functions are accessible there in sql?

595


What is a View ? Can we insert, Update and delete a view?

632


What is filestream?

562


What is the purpose of sql profiler in sql server?

517


What is the process of normalization?

562






Can a table have 2 foreign keys?

509


Does group by or order by come first?

546


Please explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?

503


Where cross join is used?

519


Can you type more than one query in the query editor screen at the same time?

578


Explain the database you used in your final year project?

539


What is the meaning of lock escalation and why/how to stop this? : sql server database administration

609


Does a full backup include transaction log?

485


How to turn on the mssql api module in php?

569


What are built in functions?

580