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 / rakesh prasad
select name ,count(name)as cnt from (
select case when ((name ='a') or (name = 'b') )then name
else
'others' end as 'name' from tbl_count ) as temp group by
name
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Where the sql database files are stored?
Is it possible to read/write files to-and-from PL/SQL?
what happens when the column is set to auto increment and you reach the maximum value for that table? : Sql dba
write an sql query to find names of employee start with 'a'? : Sql dba
What is full join?
What are functions in sql?
how are mysql timestamps seen to a user? : Sql dba
When can we use the where clause and the having clause?
How do I view tables in mysql?
What is the reports view in oracle sql developer?
If i can use sys.check_constraints to display my constraints from my database using sql server 2005, how can i display then if i am using sql server 2000????
What is difference between ms sql and mysql?
Mention what are the benefits of pl/sql packages?
What does := mean in pl sql?
What is a variable in sql?