Consulting

Results 1 to 4 of 4

Thread: Get Newest Price from Table for Each Product Code

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Get Newest Price from Table for Each Product Code

    I need to create a query that always pulls the newest price from each PC. Here is the SQL that I tried but I am getting a syntax error:

    SELECT ATLN_PRC_RTG_BASE.PC,  ATLN_PRC_RTG_BASE.PRICE where ATLN_PRC_RTG_BASE.SDATE IN
    (SELECT Max([ATLN_PRC_RTG_BASE].[SDATE]) from ATLN_PRC_RTG_BASE where ATLN_PRC_RTG_BASE.PC==ATLN_PRC_RTG_BASE2.PC);
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

  2. #2
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    257
    Location
    Your SQL shows 2 adjacent = signs.

    .....ASE.PC==ATLN_PRC....

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Still an Error. I didn't think that was it because I pulled it from someone else's code (on the web) that worked and modified it for my own.
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

  4. #4
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    257
    Location
    I see a BASE2 in your original SQL. I've tried to use an alias on the table and adjust the sql. (Untested)

    SELECT
    Base2.PC
    , Base2.PRICE
    FROM ATLN_PRC_RTG_BASE as Base2
    where
    Base2.SDATE In
    (SELECT Max([ATLN_PRC_RTG_BASE].[SDATE]) from ATLN_PRC_RTG_BASE where ATLN_PRC_RTG_BASE.PC=Base2.PC);

Posting Permissions

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