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 / vivek nagarajan
SELECT SUM(DECODE(txt,'a',1)) a_count,
SUM(DECODE(txt,'b',1)) b_count,
SUM(DECODE(txt,'a',0,'b',0,1)) others_count
FROM t1;
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
How would you reference column values before and after you have inserted and deleted triggers?
what is schema? : Sql dba
How can I see all tables in sql?
Is subquery faster than join?
Can %notfound return null after a fetch?
What operating systems are supported by oracle sql developer?
What is dense_rank?
How is debugging done?
When to use inner join and left join?
What is the purpose of the partition table?
what is cursor and its type, what is ref cursor write a syntax to pass ref cursor into procedure out fucntion and call the procedure
Explain what is rdbms?
What is t sql used for?
What is sqlservr exe?
How do I run a program in pl sql?