Re: use of except
On 2011-10-17 04:39, elodie wrote:
> Hi everyone,
>
> I would appreciate if someone could help me fix the following sql
> query.
>
> The goal of the query is to find those years and months where a total
> is either less than 50 or more than 100.
>
> SELECT month, year, MAX(nsick)
> FROM sick
> GROUP BY month, year
> EXCEPT
> SELECT month, year, MAX(nsick)
> FROM sick
> GROUP BY month, year
> HAVING MAX(nsick)>50 AND MAX(nsick)<100;
>
I think that Oracle uses MINUS instead of EXCEPT (as Michel pointed
out). Another possibility:
SELECT month, year, MAX(nsick)
FROM sick
GROUP BY month, year
HAVING MAX(nsick)<=50 OR MAX(nsick)>=100;
/Lennart
|