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 / manoj pandey
select 'No of students in class ' + cast(classname as char(2)) + ' : ' + cast(count(*) as char(5)' from students group by classname
For more Interview Questions check my blog: http://sqlwithmanoj.wordpress.com/interview-questions/
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a non-clustered index?
What is the difference between varchar and nvarchar datatypes?
What is full outer join in sql server joins?
How retrieve field names from the table in SQL through JAVA code?
Explain system scalar functions?
Explain what is it unwise to create wide clustered index keys?
Describe in brief authentication modes in sql server.
What is a document index?
Explain the disadvantages/limitation of the cursor?
Explain the Ways to improve the performance of a sql azure database?
What types of replication are supported in sql server?
What is microsoft sql server?
What is sql injection? How to protect against sql injection attack?
How to convert character strings into numeric values?
What is the difference between executequery () and executeupdate ()?