Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Can you please explain the difference between function and stored procedure?

961


List the different types of joins?

929


How to specify the collation for a character data type in ms sql server?

965


OPTIMIZATION OF SP,CURSOR,TRIGGERS

2707


What is the bookmark lookup and rid lookup?

943


Do you know sql server 2008 backup compression?

922


Do you know what are the differences between lost updates and uncommitted dependencies?

1010


How can sql server instances be hidden?

896


Define inner join in sql server joins?

991


How to list all columns in a table using odbc_columns()?

937


Explain what are commit and rollback in sql?

867


What is default port number for sql server 2000?

993


what is an index? : Sql server database administration

935


To which devices can a backup be created and where should these devices be located? : sql server management studio

972


How we can refresh the view?

1058