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
Does server sql treat char as a variable-length or fixed-length column?
Explain hostprotectionattribute in sql server 2005?
Explain a differential backup?
Introduction of rollup clause using sum and group by clause?
query processing
Explain how does the report manager work in ssrs?
How to move database physical files in ms sql server?
What is raiseerror? What is raiseerror?
What are system databases in ms sql server?
What are sub reports and how to create them?
What is triggers and its types?
What is subquery? Explain the properties of a subquery?
What is the default sql server instance name?
What is a field in a table?
What is sqlservr.exe - process - sql server (sqlex?press)?