query for a group of line

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

let say I have a table like that

id1 id2 data
---------------
1 1 kmhkjhkj
2 3 k,wenlfwep
3 2 ;vcjefeporuf [e
4 1 eep poerjfe poj
5 3 wlu woiu owoi

how do I get all the line with id2 equal to its greatest value, that is:
2 3 k,wenlfwep
5 3 wlu woiu owoi

I don't want to write
"WHERE id2 = 3", I want to write something like
"WHERE id2 IS MAXIMUM" ?!?!

anyway of achieveing that?
 
I tried something like that but it failed:
SELECT *
FROM Tselect
ORDER BY id2 DESC
WHERE id2 IN
(SELECT MAX(id2) AS id2
FROM Tselect)

beside, ultimately my id2 column won't be an int but a datetime, any more
hint?
 
I found it, simply:
SELECT *
FROM Tselect
WHERE (id2 =
(SELECT MAX(id2)
FROM Tselect))
 
Back
Top