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

select decode (col1,'a','a','b','b','others') col1,count(col1) from T1 group by decode (col1,'a','a','b','b','others')

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how are mysql timestamps seen to a user? : Sql dba

199


what is oracle database ? : Sql dba

186


what are wild cards used in database for pattern matching ? : Sql dba

191


Why do we use sql constraints? Which constraints we can use while creating database in sql?

205


What is the difference among union, minus and intersect?

192






what is auto increment? : Sql dba

210


What are the parameter modes supported by pl/sql?

179


What is the advantage of index in sql?

172


How do I edit a trigger in sql developer?

139


How to get list of all tables from a database?

208


how to check server status with 'mysqladmin'? : Sql dba

174


Can a composite key be null?

150


Why is theta join required?

171


how can we destroy the session, how can we unset the variable of a session? : Sql dba

186


What is program debugging?

149