PDA

View Full Version : Problem to find the good request



fredkrug
04-21-2015, 02:56 PM
Hi,
I have a problem to find the good request in this case :
I have this table :

Building Owner NbAppart
A X 5
A Y 3
A Z 4
B X 2
B Y 6
B Z 0
C X 4
C Y 0
C Z 2
I want to extract the buildings where the owner is X and has more apartments than others owners in each building, that is in this case the buildings A and C.
The request should start like this :
SELECT Building FROM MATABLE WHERE Owner=X AND NbAppart =MAX(...
But I don't know how to finish this request.

Thanks for your help