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








Answers were Sorted based on User's Feedback



Table name: T1, it has only one column. col1 ------ c b a b b b b d s a a t s ..

Answer / dinakar

select col1,count(*) cnt from T1 where col1 in
(select distinct col1 from T1 )
group by col1

Is This Answer Correct ?    1 Yes 6 No

Post New Answer

More SQL PLSQL Interview Questions

How many unique keys can a table have?

0 Answers  


Does truncate require commit?

0 Answers  


suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we find 4th and 5th highest salary and 1 to 10 highest salary

7 Answers  


What is meant by Join? What are the different types of Joins available? Explain.

5 Answers   Cap Gemini,


How to display the current date in sql?

0 Answers  






Can we create index on primary key?

0 Answers  


Hi all, I am going to write oracle certification. Can anyone send me the dumps available if any for OCA exam? Its really very urgent, prompt response will help me alot..

8 Answers  


Hi all, i have a table as follows empid empname mgrid deptid 1 a 3 4 2 b 1 5 3 c 2 3 4 d 3 6 5 e 4 7 i want the output as empname mgrname a c b a c b d c e d

4 Answers  


How do I create a sql script?

0 Answers  


What is delete command in sql?

0 Answers  


What is hibernate and its relation to sql?

0 Answers  


How do I upgrade sql?

0 Answers  


Categories