tags:

views:

118

answers:

2
SELECT h11, HA11
FROM florin.h11
WHERE (3>d1 AND 3<d2) OR (3>d1 AND 3=d2 AND id=MAX(id))
UNION (3=d1 AND 3<d2 AND id=MIN(id));

Here a screenshot of my table stucture: alt text

A: 
Parth
Third wrong thing is you probably want a subselect where you are using max(id), but I cannot tell what your goal is.
MJB
+1  A: 

I think what you would like to do is something like this:

SELECT h11, HA11
FROM florin.h11 
WHERE (3>d1 AND 3<d2) 
   OR (3>d1 AND 3=d2 AND id = (SELECT MAX(t2.id) 
                               FROM florin.h11 AS t2))
   OR (3=d1 AND 3<d2 AND id = (SELECT MIN(t3.id)
                               FROM florin.h11 AS t3));
Marga Keuvelaar
Why do you use the `UNION` instead of another `OR`?
Peter Lang
because there was a union in the original query, but it doesn't make much sense, now that i have a closer look...
Marga Keuvelaar
i removed the union, and changed it into an or
Marga Keuvelaar