Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2011
    Posts
    4

    SQL command convert into access

    select Saler, Model, Price, DDate
    from DB_Table where DDate in
    (select max(DDate) from DB_Table where Valid = 'ok' group by Saler, Model)



    How can I make it work in ms access 2007?
    I am trying to get valid (ok) price for Saler-Model group at max date.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Is this what you're trying to do?

    http://www.baldyweb.com/LastValue.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,745
    Try this (untested)

    select Saler
    , Model
    ,Price
    from DB_Table
    where
    DDate =(select max(DDate)
    from DB_Table
    where Valid = "ok")
    group by Saler, Model,Price

  4. #4
    Join Date
    Dec 2011
    Posts
    4
    Quote Originally Posted by pbaldy View Post
    Is this what you're trying to do?

    http://www.baldyweb.com/LastValue.htm
    Thank you for the reply,

    It is a 2 layer solution with 2 query.
    I want to make it in a single query.

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Not sure why, but:

    SELECT VehicleMiles.*
    FROM VehicleMiles INNER JOIN [SELECT Max([VehicleMiles].[DorDate]) AS MaxDate, [VehicleMiles].[CarNum]
    FROM VehicleMiles
    GROUP BY [VehicleMiles].[CarNum]]. AS qryMaxDates ON (VehicleMiles.CarNum = qryMaxDates.CarNum) AND (VehicleMiles.DorDate = qryMaxDates.MaxDate);
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-25-2011, 11:16 AM
  2. Replies: 9
    Last Post: 08-07-2011, 11:21 AM
  3. Convert access 2003 to access 2010
    By Vera in forum Access
    Replies: 3
    Last Post: 07-16-2010, 11:01 AM
  4. Convert query sql server for Access
    By webtony in forum Queries
    Replies: 0
    Last Post: 06-23-2009, 02:46 AM
  5. Convert Excel Macro to Access Query
    By crownedzero in forum Queries
    Replies: 1
    Last Post: 06-22-2009, 02:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums