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

how to dump a table to a file with 'mysqldump'? : Sql dba

1044


How does sql developer connect to oracle database?

1009


Can a view be mutating? If yes, then how?

1035


What does rownum mean in sql?

1037


What is nested table in pl sql?

1080


Is and as keyword in pl sql?

969


What is multiple partition?

973


What are the different ways to optimize a sql query?

953


what is “go” in t-sql? : Transact sql

1118


What is sql rowcount?

1035


Is sql a case sensitive language?

953


what is the command line end user interface - mysql? : Sql dba

987


How to return an array from java to pl/sql?

1149


What is trigger explain it?

1021


what is online transaction processing (oltp)? : Sql dba

1002