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 you please explain the difference between function and stored procedure?
List the different types of joins?
How to specify the collation for a character data type in ms sql server?
OPTIMIZATION OF SP,CURSOR,TRIGGERS
What is the bookmark lookup and rid lookup?
Do you know sql server 2008 backup compression?
Do you know what are the differences between lost updates and uncommitted dependencies?
How can sql server instances be hidden?
Define inner join in sql server joins?
How to list all columns in a table using odbc_columns()?
Explain what are commit and rollback in sql?
What is default port number for sql server 2000?
what is an index? : Sql server database administration
To which devices can a backup be created and where should these devices be located? : sql server management studio
How we can refresh the view?