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

select decode(col1,'a','a','b','b','Other') "col1",count
(col1) "countval"
from col group by col1;

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is a trigger used?

165


What is using in sql?

160


Is sql a oracle?

161


What are the uses of sysdate and user keywords?

217


How to write a query to show the details of a student from students table whose

193






explain the difference between bool, tinyint and bit. : Sql dba

169


Does mysql support pl sql?

160


How many sql statements are used? Define them.

194


How can a function retun more than one value in oracle with proper example?

196


how do you login to mysql using unix shell? : Sql dba

199


What is db journal file?

151


How is data stored in sql?

171


What are few of the schema objects that are created using PL/SQL?

205


What is an emotional trigger?

160


What are the two types of cursors in pl sql?

150