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 decode(col1,'a','a','b','b','Other');
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Show code of a cursor for loop.
how would you write a query to select all teams that won either 2, 4, 6 or 8 games? : Sql dba
Can I call a procedure inside a function?
What is a full join?
Can we create table in function?
what is the difference between char and varchar data types? : Sql dba
Is null operator in sql?
what is a control file ? : Sql dba
what is the use of double ampersand (&&) in sql queries?
Can I learn sql in a week?
how to present a past time in hours, minutes and seconds? : Sql dba
how to include character strings in sql statements? : Sql dba
Mention what is the plv (pl/vision) package offers?
What does (*) mean in sql?
How delete all records from table in sql?