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
What is the default port for SQL Server over a firewall?
Write a query to find 5th highest amount paid from the customer table.
What is change tracking in sql server?
What are diverse clauses that form a part of sql?
How to provide default values to stored procedure parameters?
Explain collation?
Do you know spatial data types - geometry and geography in sql server 2008?
What is an execution plan? When would you use it?
What is the purpose of a table?
what are constraints? : Sql server database administration
How to make a remote connection in a database?
Explain various data region available in ssrs with their use?
is there a column to which a default can't be bound? : Sql server database administration
Is mysql better than sql server?
Can you explain full-text query in sql server?