Results 1 to 4 of 4

Thread: need help: 2 Left Joins...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    313

    need help: 2 Left Joins...

    I am using vb6 and sql server 2000.

    I need join 3 tables Stops, Trans, Comms.
    Stops
    Left join Trans t on stops.stop_num = trans.stop_num and stops.stopdate = trans.trandate
    and stops.route_num = trans.route_num
    Where itemid <> "NOPU"

    left join Comms on comms.commid = trans.commodity

    Where t.TranType = "P"
    SUM(Qty) and Sum(Amount) where commodity = C as Tot Cash Pieces PU and Tot Cash Amount PU
    SUM(Qty) and Sum(Amount) where comms.code = "BA" or "BO" as Tot Coin Pieces PU and Tot Coin Amount PU

    Where t.TranType = "D"
    SUM(Qty) and Sum(Amount) where commodity = C as Tot Cash Pieces Del and Tot Cash Amount Del
    SUM(Qty) and Sum(Amount) where comms.code = "BA" or "BO" as Tot Coin Pieces Del and Tot Coin Amount Del

    I know I need left join Trans and then Trans left join Comms:
    I have code like this:
    Code:
      .......
      strSQL = strSQL & "FROM Stops s  "
      strSQL = strSQL & "Left Join Trans t ON (s.Stop_Num = t.stop_num "
      strSQL = strSQL & "AND s.StopDate = t.TranDate "
      strSQL = strSQL & "AND s.Route_Num = t.Route_Num) "
      ????
    How do I write the 2nd left Join?
    Thanks a lot.

  2. #2
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: need help: 2 Left Joins...

    You again continue writing the joining..

    Meaning continue ...

    left join <table3> t3 on ().....
    Regards
    Srinivasan Baskaran
    India

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: need help: 2 Left Joins...

    Moved to Database Development

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    313

    Re: need help: 2 Left Joins...

    Quote Originally Posted by cheenu_vasan
    You again continue writing the joining..

    Meaning continue ...

    left join <table3> t3 on ().....
    Thanks. I added code like this:
    Code:
    strSQL = strSQL & "LEFT JOIN Comms m ON t.Commodity = m.CommId) "
    How do I do the SUM(QTY) part?

    Thanks again.

Posting Permissions

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



Click Here to Expand Forum to Full Width