Re: Why doesn't this work?

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 06/18/04


Date: Fri, 18 Jun 2004 23:10:30 +0200

On Fri, 18 Jun 2004 13:47:01 -0700, D Mack wrote:

>Can anyone give me a clue? Please! The first part, before the and, works perfectly, but the remainder does not return the appropriate rows.
>
>select shop_person from ae_p_wka_e where
>(convert(char(10), ae_p_wka_e.sched_date, 101)) = (convert(char(10), getdate() - 2, 101)) and ae_p_wka_e.shop_person not in
>(select shop_person from ae_l_shp_d where ae_l_shp_d.shop_person = ae_p_wka_e.shop_person)
>
>Thanks.

Hi D,

The subquery finds all shop_persons in ae_l_shp_d (awful table names, by
the way) that are EQUAL to the shop_person in ae_p_wka_e; the not in then
says that no shop_person from this subquery may be equal - of course, this
will exclude any row.

Why don't you explain what you want to achieve. Begin by posting your DDL
(CREATE TABLE statements, including constraints), so we get to know what
your tables look like. Explain your business need; include illustrative
sample data (as INSERT statements, so we can cut and paste it onto our
databases for testing) and expected output.

Without DDL and sample data, with only a query and a "it does not work!",
we have precious little to go on!

Best, Hugo

-- 
(Remove _NO_ and _SPAM_ to get my e-mail address)


Relevant Pages

  • Re: UDF and SQL2000 - Why doesnt this work?
    ... Basically This is what I want to do - I have created a query ... as DDL (i.e. CREATE TABLE statements; ... Sample data that illustrates the problem, ... Expected output from the sample data supplied; ...
    (microsoft.public.sqlserver.programming)
  • RE: SELECT stmt question
    ... Can you post some DDL, sample data and expected result? ... "joe" wrote: ... > query. ...
    (microsoft.public.sqlserver.programming)
  • Re: New to SQL and trying multiple table joins
    ... > Can't be certain of how to write this query for you without DDL (CREATE ... Sample data is no issue, but I was worried about the DDL. ... in the CurrentJob the ODBC manager always asks me to select keys.. ...
    (microsoft.public.sqlserver.programming)
  • Re: MULTIPLE TABLE QUERY!
    ... It's difficult to know how to help you write your query without DDL and ... sample data. ... > Above is my feeble attempt. ...
    (microsoft.public.sqlserver.server)
  • Re: Best scenario for FREETEXTTABLE
    ... Can you post table DDL and sample data? ... consider using a subquery to restrict the set returned by one of the ...
    (microsoft.public.sqlserver.fulltext)