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 / sankarapandian

SELECT SUM(case when col1='a' then 1 else 0 end) a_count,
SUM(case when col1='b' then 1 else 0 end)
b_count,
sum(case when col1!='a' and col1!='b' then 1
else 0 end)other_count
FROM t1

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is user in sql?

970


Does sql use python?

978


What are the types of join and explain each?

989


explain normalization concept? : Sql dba

998


Explain ttitle and btitle.

1058


What are the different dml commands in sql?

1090


What is the benefit of foreign key?

962


What is difference sql and mysql?

943


Does varchar need length?

933


What is a data manipulation language?

966


What is basic structure of pl sql?

990


what is sql? : Sql dba

973


How do I run a script in sql developer?

901


How do sql triggers work?

989


what's the difference between a primary key and a unique key? : Sql dba

973