subquery problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dave

    #1

    subquery problem

    I'm trying to get the fundnames that are in secondary data but not in
    UpToDateFunds.
    UpToDateFunds is a query that returns fundname.
    below is sql i have that does not work as planned.
    can you tell me whats wrong here?
    If a put a select statement in place of the UpToDateFunds query it
    runs forever before returning the data set.

    SELECT [SecondaryData].[fundname]
    FROM SecondaryData
    WHERE [SecondaryData].[fundname] Not in ([UpToDateFunds].[fundname]);


  • Linda Burnside

    #2
    Re: subquery problem

    I think you may something like

    SELECT [SecondaryData].[fundname]
    FROM SecondaryData LEFT JOIN [UpToDateFunds].[fundname]
    WHERE [UpToDateFunds].[fundname] is null;

    Linda



    "dave" <spammer@nospam mer.net> wrote in message
    news:uSLlf.1715 $wP3.888@bignew s6.bellsouth.ne t...[color=blue]
    > I'm trying to get the fundnames that are in secondary data but not in
    > UpToDateFunds.
    > UpToDateFunds is a query that returns fundname.
    > below is sql i have that does not work as planned.
    > can you tell me whats wrong here?
    > If a put a select statement in place of the UpToDateFunds query it
    > runs forever before returning the data set.
    >
    > SELECT [SecondaryData].[fundname]
    > FROM SecondaryData
    > WHERE [SecondaryData].[fundname] Not in ([UpToDateFunds].[fundname]);
    >
    >[/color]


    Comment

    • Rich P

      #3
      Re: subquery problem

      Hi Dave,

      Try your query this way

      SELECT [SecondaryData].[fundname]
      FROM SecondaryData
      WHERE [SecondaryData].[fundname] Not in (Select
      [UpToDateFunds].[fundname] From UpToDateFunds Group By
      [UpToDateFunds].[fundname]);

      The Group By clause ensures that the fundname will be distinct in the
      subquery.

      Rich

      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      Working...