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
Can there be 2 primary keys in a table?
what is clause? : Sql dba
What is trigger and types?
What are the conditions an underlying table must satisfy before a cursor can be used by a positioned update or delete statement? : Transact sql
Does sqlite need a server?
What is integrity in sql?
how to decrement dates by 1 in mysql? : Sql dba
Is left join inner or outer?
what is the difference between ereg_replace() and eregi_replace()? : Sql dba
What are user defined functions?
What is difference between stored procedure and trigger?
Which join is like inner join?
What is sharding in sql?
What is the difference between delete and truncate commands?
How do sql databases work?