Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Posts
    8

    Unanswered: Need Help for my SQL statement

    Dear all,

    As I'm a real beginner in SQL, I need some help to improve my follwing statement :

    ------------------
    Select Champ1, Champ2, Champn from TABLE1
    INNER JOIN TABLE2
    ON TABLE1.Champ1 = TABLE2.Champ1 and TABLE2.Date = (Select
    Max(TABLE2.Date) FROM TABLE2)
    WHERE TABLE1.Date = <CONSTANT>
    ------------------

    I need to modify my SQL to instead of picking up the Max of date in TABLE2, I pick up the same date than the one chosen in TABLE1.date (the value is indeed <CONSTANT>

    How can do that ?

    Thanks in advance for your help

  2. #2
    Join Date
    Mar 2004
    Posts
    8

    Need Help on SQL Statement

    Dear all,

    As I'm a real beginner in SQL, I need some help to improve my follwing statement :

    ------------------
    Select Champ1, Champ2, Champn, Date from TABLE1
    INNER JOIN TABLE2
    ON TABLE1.Champ1 = TABLE2.Champ1 and TABLE2.Date = (Select
    Max(TABLE2.Date) FROM TABLE2)
    WHERE TABLE1.Date = <CONSTANT>
    ------------------

    I need to modify my SQL to instead of picking up the Max of date in TABLE2, I pick up the same date than the one chosen in TABLE1.date (the value is indeed <CONSTANT>

    How can I do that ?

    Thanks in advance for your help

  3. #3
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Get rid of the select for TABLE2.Date and make it an equijoin to TABLE1.Date

    -- This is all just a Figment of my Imagination --

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Code:
    Select	Champ1,
    	Champ2,
    	Champn,
    	Date
    from	TABLE1
    	INNER JOIN TABLE2
    	    ON TABLE1.Champ1 = TABLE2.Champ1
    	    and TABLE1.Date = TABLE2.Date
    WHERE TABLE1.Date = <CONSTANT>
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    You need this?
    and TABLE2.Date=TABLE1.Date

    If not maybe some sample data and expected result will help me understand

  6. #6
    Join Date
    Mar 2004
    Posts
    8
    Many Thanks,
    Cheers, Arcondo

  7. #7
    Join Date
    Mar 2004
    Posts
    8
    many thanks for your help

Posting Permissions

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