I have also a question regarding distinct and/or group by. My table as follow:
| art | ean | obs | vke |
---------------------------------------------------
| type | 1234567890123 | 1 | 100 |
| type | 1234567890123 | 0 | 50 |
| type | 1234567890123 | 0 | 60 |
| type | 1234567890123 | 0 | 70 |
I need the query to select always the row with obs = 1 and only the cheapest of the others with obs = 0. All other equal EAN should not be listed at all. Is this possible ?
So the result should be:
| type | 1234567890123 | 1 | 100 |
| type | 1234567890123 | 0 | 50 |
I’d
uniontwo results first one are all rows withobsaquals1and the second all rows grouped byart,ean,obswithobsequals0andminvalue ofvke.Read more about
unionandgroup by.