Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: How to do a difference on two sets from same table?

Re: How to do a difference on two sets from same table?

From: Dan <dan_at_nospam.com>
Date: Tue, 31 Aug 2004 09:01:16 -0500
Message-ID: <Bw%Yc.5$2A3.984@news.uswest.net>


Alas, my BRIO sql query tool (using odbc against ms sql server) does not support MINUS or EXCEPT.

Thanks,
Dan

On 8/30/2004 10:26 PM, Alan wrote:
> Complete SQL? Can we have your complete salary (or grade)? Minus:
>
> SELECT your_columns_of_interest
> FROM wherever
> WHERE some_condition
> MINUS
> SELECT same_columns_as_above
> FROM same_place
> WHERE other_condition
>
> You are subtracting one set from another set. It is important to keep the
> set notion in mind when you construct this and interpret the results. In the
> above, you will see all rows that are in the first part of the query, but
> are not in the 2nd part.
>
> You must learn how to use MINUS. It is as important as joins.
>
>
> "Dan" <dan_at_nospam.com> wrote in message
> news:uNIYc.27$5p3.18307_at_news.uswest.net...
>

>>I don't know what you mean.  Could someone give me the complete SQL?
>>
>>TIA,
>>Dan
>>
>>On 8/30/2004 2:55 AM, pstnotpd wrote:
>>
>>>Have a look at MINUS
>>>
>>>
>>>Dan wrote:
>>>
>>>
>>>>Hi,
>>>>
>>>>Say I have a sales history table that has the following fields:
>>>>custid, invoicedate, prodid, quantity, cost, sale.  And that I want to
>>>>select sales records where invoicedate is between 5/1/04 and 8/31/04
>>>>and where these are new sales for each customer, meaning that the
>>>>customer did not buy the prodid in the period 1/1/04 to 4/30/04.  I
>>>>know conceptually that this is a difference between two sets based on
>>>>custid+prodid but I don't know how to express this in SQL.  Please

>
> help.
>

>>>>TIA,
>>>>Dan Received on Tue Aug 31 2004 - 09:01:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US