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

select decode(dept_id,1,1,2,2,0) "cnt" ,count(decode
(dept_id,1,1,2,2,0))
from deps group by decode(dept_id,1,1,2,2,0);

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 aggregate function in sql?

1032


How many sql core licenses do I need?

944


How do you know if a relationship is 2nf?

942


what are the differences among rownum, rank and dense_rank? : Sql dba

1038


How would you pass hints to the sql processor?

980


Why schema is used in sql?

1047


What is the maximum rows in csv?

920


What is an intersect?

1100


what is meant by urlencode and urldocode? : Sql dba

1172


How do you respond to dementia behavior?

964


How to run sql statements with oracle sql developer?

1063


What are tables and fields?

1030


How do I copy a table in sql?

983


What do you mean by query optimization?

999


Can we join 3 tables in sql?

1034