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 / samba shiva reddy . m

select 'No of students in class '+ CONVERT(VARCHAR,ClassName)+' : '+ convert(varchar,Count(studname)) from students
group by
classname order 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

What is the language structure to add a record to a table?

581


How to delete duplicate rows in sql server?

577


What happens if null values are involved in boolean operations?

558


Does table partitioning improve performance?

536


Explain why variables called the most powerful component of ssis?

535






What is the difference between inner join and equi join?

492


What is difference between sql and sql server?

546


Explain different types of self contained sub query?

546


Explain boyce and codd normal form(bcnf)?

537


Explain iaas, paas and saas?

74


Why use view instead of a table?

521


How does normalization work?

504


Explain the working of sql privileges?

611


How do I delete a sql server database?

549


Mention the different types of replication in sql server.

561