tags:

views:

46

answers:

5

I have this table:

-------
id a b
-------
1  1 1
2  1 5
3  1 1
4  1 1
5  1 6

How do I select this?

-------
id a b
-------
1  1 1
2  1 5
5  1 6
+1  A: 

Try:

SELECT MIN(id), a, b FROM table GROUP BY a, b
Alex Humphrey
+1  A: 
select id, a, b from table 
where id in (1,2,5)
+1  A: 
SELECT MIN(id), a, b
FROM table
GROUP BY a,b
Chris Diver
+1  A: 
select min(id), a,b from foo group by a,b;
Luther Blissett
+1  A: 

THe below would get you what you want in your example but i am not sure if the min ID is useful if it is the key.

SELECT MIN(id), a, b
FROM table
GROUP BY a,b
Ben Robinson