Re: Select statment

From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 03/12/04


Date: Fri, 12 Mar 2004 18:16:52 -0000

What happens when you run the query? Error? Unexpected results?

Try this:

SELECT *
    FROM dba.case_incident
    WHERE case_incident_key
        NOT IN
        (SELECT case_incident_key
            FROM dba.report
            WHERE case_incident_key IS NOT NULL)

(NOT IN won't return anything if there are NULLs in the subquery)

If that doesn't help post a script, including DDL, to reproduce the problem.

-- 
David Portas
SQL Server MVP
--


Relevant Pages

  • Re: question about "not exists"
    ... Usually an EXISTS subquery is correlated but this one isn't so it will ... Here's an example of a correlated NOT EXISTS query (using the Pubs ... This retrieves all the Books (Titles) that have never been sold (no row ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Table Data Comparison
    ... If Tbl2.d2 includes any NULLs then your NOT IN query won't return any rows ... because the NOT IN comparison is UNKNOWN. ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Why doesnt this work?
    ... Do you have any NULLs for the column shop_person in table ae_l_shp_d? ... Change your query as: ... note the explicit column aliasing in the subquery SELECT list. ...
    (microsoft.public.sqlserver.programming)
  • Re: [SQL update question]
    ... > Remove GROUP BY from your subquery and it should work the way you expect. ... > when you query the table. ... > David Portas ... > SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • RE: [SQL update question]
    ... Remove GROUP BY from your subquery and it should work the way you expect. ... when you query the table. ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)

Quantcast