dbTalk Databases Forums  

use of except

comp.databases.oracle.tools comp.databases.oracle.tools


Discuss use of except in the comp.databases.oracle.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
elodie
 
Posts: n/a

Default use of except - 10-16-2011 , 09:39 PM






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 get the following error message:
EXCEPT
*
ERROR at line 4:
ORA-00933: SQL command not properly ended

Thanks in advance

Reply With Quote
  #2  
Old   
Michel Cadot
 
Posts: n/a

Default Re: use of except - 10-16-2011 , 11:15 PM






"elodie" <elodie.gillain (AT) gmail (DOT) com> a écrit dans le message de news:
d16e6671-ec5c-417c-af18-89721b386dc9...oglegroups.com...
Quote:
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 get the following error message:
EXCEPT
*
ERROR at line 4:
ORA-00933: SQL command not properly ended

Thanks in advance
MINUS

Regards
Michel

Reply With Quote
  #3  
Old   
Lennart Jonsson
 
Posts: n/a

Default Re: use of except - 10-17-2011 , 02:19 PM



On 2011-10-17 04:39, elodie wrote:
Quote:
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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.