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 / kumarvijay
select decode(dept_id,1,1,2,2,0) "cnt" ,count(decode
(dept_id,1,1,2,2,0))
from deps group by decode(dept_id,1,1,2,2,0);
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
how to dump a table to a file with 'mysqldump'? : Sql dba
How does sql developer connect to oracle database?
Can a view be mutating? If yes, then how?
What does rownum mean in sql?
What is nested table in pl sql?
Is and as keyword in pl sql?
What is multiple partition?
What are the different ways to optimize a sql query?
what is “go” in t-sql? : Transact sql
What is sql rowcount?
Is sql a case sensitive language?
what is the command line end user interface - mysql? : Sql dba
How to return an array from java to pl/sql?
What is trigger explain it?
what is online transaction processing (oltp)? : Sql dba