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 decode(col1,'a','a','b','b','Other');

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to fix oracle error ora-00942: table or view does not exist

568


How can get second highest salary in sql?

506


What is not null in sql?

575


What are the ways on commenting in a pl/sql code?

511


how to enter numeric values as hex numbers? : Sql dba

569






What does the base_object_type column shows in the user.triggers data dictionary view?

574


What is the syntax to add a record to a table?

575


how is exception handling handled in mysql? : Sql dba

552


Is there a way to automate sql execution from the command-line, batch job or shell script?

557


how to start mysql server? : Sql dba

613


What is sql and explain its components?

598


Explain the working of primary key?

607


Is it possible to Restore a Dropped Table using Rollback Command in Oracle SQL Plus ?

720


Is oracle and sql same?

575


What are the parameter modes supported by pl/sql?

533