Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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 do you know if your mysql server is alive? : Sql dba

167


List the ways to get the count of records in a table?

182


what is a table called, if it has neither cluster nor non-cluster index? What is it used for? : Sql dba

176


what is an index? : Sql dba

190


How would you convert date into julian date format?

194






What are different types of statements supported by sql?

192


What is inner join in sql?

195


What is rowtype?

160


What is a nested table in word?

165


Is json a nosql?

165


What is pl sql in dbms?

162


Why stored procedures are faster than query?

168


What is rtm in testing?

161


Name the operator which is used in the query for pattern matching?

149


What is the main reason behind using an index?

194