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 an inner join?
When to use null data driven subscription?
How do I edit a stored procedure in sql server?
what's the difference between a primary key and a unique key? : Sql server database administration
What is BCNF? How is it better than 2NF & 3NF?
What is the difference between dbcc indexdefrag and dbcc reindex?
What is hot add cpu in sql server 2008?
Explain about link server in sql server?
what is denormalization and when would you go for it? : Sql server database administration
What is replication with database mirroring? : sql server database administration
What is sql server database?
What is Sqlpaging in SqlServer 2005 ?
Explain what are the basic functions for master, msdb, model, tempdb databases?
What is the ‘fillfactor’?
How to generate random numbers with the rand() function in ms sql server?