Re: use of except

From: Lennart Jonsson <erik.lennart.jonsson_at_gmail.com>
Date: Mon, 17 Oct 2011 21:19:49 +0200
Message-ID: <j7hv4l$mhq$1_at_dont-email.me>


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 Received on Mon Oct 17 2011 - 21:19:49 CEST

Original text of this message