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...


Table name: T1, it has only one column.

col1
------
c
b
a
b
b
b
b
d
s
a
a
t
s


Requirement:

I need the following output from the above base table by
using SQL query.


col1 Cnt
----- -------
a 3
b 5
Others 5


Please help.

Thanks
Guru
v.gurus@in.com








Answer Posted / rakesh prasad

select name ,count(name)as cnt from (
select case when ((name ='a') or (name = 'b') )then name
else
'others' end as 'name' from tbl_count ) as temp group by
name

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is compilation error in pl sql?

984


What is t sql in sql server?

1078


How do I find duplicates in a single column in sql?

1023


Is it possible to pass parameters to triggers?

1104


Does group by remove duplicates?

1047


Suppose a student column has two columns, name and marks. How to get name and marks of the top three students.

1027


What are the conditions an underlying table must satisfy before a cursor can be used by a positioned update or delete statement? : Transact sql

1003


how to increment dates by 1 in mysql? : Sql dba

979


Does truncate free space?

1017


Is it possible to create startup or shutdown trigger for on-schema?

1031


What are the different parts of a package?

1116


What is break?

1201


What is function and procedure in pl sql?

1049


Are null values same as that of zero or a blank space?

1029


How many times can we commit in a loop?

1023