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 / vivek nagarajan

SELECT SUM(DECODE(txt,'a',1)) a_count,
SUM(DECODE(txt,'b',1)) b_count,
SUM(DECODE(txt,'a',0,'b',0,1)) others_count
FROM t1;

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I pipe the output of one isql to another?

991


What is meant by user defined function?

1028


What is the purpose of a secondary key?

946


How would you reference column values before and after you have inserted and deleted triggers?

1053


what is the difference between cluster and non cluster index? : Sql dba

1008


explain primary keys and auto increment fields in mysql : sql dba

953


What is field delimiter?

1037


What is a schema? How is it useful in sql servers?

1098


what is the bond code in materialized view?

2989


What is the difference between between and in condition operators?

989


Which one is better subquery or joins?

1042


What is t sql used for?

1006


How do you clear the screen in sql?

1056


What is minus?

976


What is sp_helptext?

1054