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
What is aggregate function in sql?
How many sql core licenses do I need?
How do you know if a relationship is 2nf?
what are the differences among rownum, rank and dense_rank? : Sql dba
How would you pass hints to the sql processor?
Why schema is used in sql?
What is the maximum rows in csv?
What is an intersect?
what is meant by urlencode and urldocode? : Sql dba
How do you respond to dementia behavior?
How to run sql statements with oracle sql developer?
What are tables and fields?
How do I copy a table in sql?
What do you mean by query optimization?
Can we join 3 tables in sql?