tags:

views:

44

answers:

3

If a table T1 has single column c1 with data base (a,a,b,b,b,c) write a query that gives output as

a  2
b  3
+3  A: 

Try this:

SELECT c1, COUNT(*)
FROM T1
GROUP BY c1
HAVING COUNT(*) > 1
Mark Byers
+1  A: 
SELECT c1, count(*) FROM T1 GROUP BY c1 HAVING count(*) > 1
canni
yep i notices this after submitting answer, corected
canni
+2  A: 
SELECT
    'a',
    2
UNION ALL
SELECT
    'b',
    3
Tom H.