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
How to get unique records from a table?
Does sql*plus also have a pl/sql engine?
What is lookup table in sql?
how can we transpose a table using sql (changing rows to column or vice-versa) ? : Sql dba
How can you fetch common records from two tables?
Why partition by is used in sql?
What is group function in sql?
What are % type and % rowtype?
what is datawarehouse? : Sql dba
Where do we use pl sql?
how can we optimize or increase the speed of a mysql select query? : Sql dba
What is the difference between sql and mysql?
What is the meaning of disabling a trigger?
i have some prob lem to tell me about my self in interview first round ...
how to rename an existing column in a table? : Sql dba