Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006
    Posts
    6

    Unanswered: Is this query correct

    I have two tables cd_customer and cd_customer_parent_hierarchy, I want to select all those customers from the parent table that are in the child table where the seed_flag for the child key is yes but the seed_flag for the parent is no

    SELECT ccph.parent_customer_key
    FROM cd_customer cc,
    cd_customer_parent_hierarchy ccph,
    cd_customer cc_p
    WHERE
    ccph.customer_key = cc.customer_key AND
    ccph.parent_customer_key = cc_p.customer_key AND
    CCPH.HIERARCHY_TYPE = '-' AND
    CC.SEED_FLAG = 'Y' AND
    CC_P.SEED_FLAG = 'N'

    also what would be the difference in queries if I were to add a group by ccph.parent_customer_key

    Thanks
    Last edited by mpathare; 08-01-06 at 12:58.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    query looks okay, given the fact that we can't see your table layouts nor sample data

    if you add that GROUP BY, two things happen -- the query slows down, and only unique values will be returned
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •