Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2013
    Posts
    2

    VBScript / help needed with query

    Hi!
    I'm trying to build a query that will access three tables and I want to run this query via VBscript.

    This is my working version:
    Code:
    sSQL = "SELECT OPNPOS.FUND, SECRTY.TKR, SECRTY.ISIN, OPNPOS.QTY, OPNPOS.LCL_ACCINC, PRIHST.PRICE / SECRTY.FACTOR AS CENA 
    FROM OPNPOS INNER JOIN (SECRTY INNER JOIN PRIHST ON SECRTY.TKR = PRIHST.TKR) ON OPNPOS.TKR = SECRTY.TKR 
    WHERE OPNPOS.FUND IN " & sFUND & " AND PRIHST.PRCDATE = #" & sDATA & "# 
    ORDER BY OPNPOS.FUND"
    I need to change this query in order to see every element from OPNPOS table so I would change
    Code:
    FROM OPNPOS INNER JOIN
    to
    Code:
    FROM OPNPOS LEFT JOIN
    but it gives me an error.

    I know that there are some ways to workaround this but I've tried a lot of combinations and get no success ;/

    Anyone can help me?

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    14,948
    I'm actually rather surprised that the code you posted will run "as is" but what you need is probably:
    Code:
    sSQL = "SELECT OPNPOS.FUND, SECRTY.TKR, SECRTY.ISIN, OPNPOS.QTY, OPNPOS.LCL_ACCINC
    , PRIHST.PRICE / SECRTY.FACTOR AS CENA FROM OPNPOS LEFT JOIN SECRTY ON 
    OPNPOS.TKR = SECRTY.TKR INNER JOIN PRIHST ON SECRTY.TKR = PRIHST.TKR
    WHERE OPNPOS.FUND IN " & sFUND & " AND PRIHST.PRCDATE = #" & sDATA & "# 
    ORDER BY OPNPOS.FUND"
    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jan 2013
    Posts
    2
    Thanks for answer. It doesn't work. I have attached error message.
    Attached Thumbnails Attached Thumbnails error.JPG  

Posting Permissions

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