Thread: help on query

help on query

From
"Sziklai Gabor"
Date:
Greetings,

There are several methods:

1/
SELECT idTableB FROM B WHERE idTableA =1
EXCEPT
SELECT idTableB FROM B WHERE idTableA =2


2/
SELECT idTableB, MAX(idTableA)
FROM B
GROUP BY idTableB
HAVING MAX(idTableA) = 1

3/
SELECT idTableB FROM
(SELECT DISTINCT ON (idTableB) idTableB, idTableA
FROM B
ORDER BY idTableB, idTableA DESC) aa
WHERE idTableA = 1

Gabor