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
Can a trigger be created on a view?
what is an extended stored procedure? : Sql server database administration
How to create stored procedures with parameters in ms sql server?
How many types of attribute relationships are there? : sql server analysis services, ssas
What is the difference between seek predicate and predicate?
What is an execution plan? When would you use it?
How to choose all records from the table?
What is the dbcc command and why is it used?
How do I open port 1433?
What are the different Authentication modes in SQL Server and how can you change authentication mode?
What is ms sql server reporting services?
what is the difference between a primary key and a unique key? : Sql server database administration
What are the types of indexing?
What is factless fact table? : sql server analysis services, ssas
Which are the two editions in which SQL Azure database available?