Hi im not a native speaker and im not into sql language. I can do some standard queries like select * from table… update and so on but have no expierience in deeper sql questions.
plz | ort | gemeinde |
---|---|---|
1000 | uttenthal | buchkirchen |
1000 | buchkirchen | buchkirchen |
2000 | mistelbach | buchkirchen |
2000 | unterholz | buchkirchen |
I have a table like this and need to get a list of plz where ort <> gemeinde but only when there is no case where ort=gemeinde for this plz.
In this example i only should get plz 2000 because there exists a entry where ort buchkirchen = gemeinde buchkirchen for plz 1000.
2
Answers
You can use
Not Exists
You can achieve this by using
GROUP BY
andHAVING
: