Results 1 to 4 of 4
  1. #1
    enroque is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    2

    Syntax error (operator missing) in query-expression

    Hi there,

    I've little experience programming queries in Access and I can't figure out why the error in Title is happening when I try to execute the following query:
    --------------------------------------------------------------
    select
    SinceTo.ID, Registros1.Price as Initial, Registros2.Price as Final
    from
    (


    select
    ID, min(fecha) as firstdate, max(fecha) as lastdate
    from
    Registros
    group by ID
    ) as SinceTo
    inner join Registros as Registros1 on Registros1.fecha = SinceTo.firstdate AND Registros1.ID=SinceTo.ID
    inner join Registros as Registros2 on Registros2.fecha = SinceTo.lastdate AND Registros2.ID=SinceTo.ID
    --------------------------------------------------------------
    The table Registros does only contain 3 fields:
    * ProductID
    * Date (=fecha)
    * Price for each Date

    And the query tries to get the Initial Price and the Last Price for each ProductID.

    Does anyone have an idea of where the error is? Thank you in advance!!

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try this:
    Code:
    SELECT 
    SinceTo.ID, Registros1.Price AS Initial, Registros2.Price as Final
    FROM 
    ((select 
    ID, min(fecha) as firstdate, max(fecha) as lastdate
    from 
    Registros
    group by ID
    )  AS SinceTo 
    INNER JOIN Registros AS Registros1 ON (SinceTo.firstdate = Registros1.fecha) AND (SinceTo.ID = Registros1.ID)) 
    INNER JOIN Registros AS Registros2 ON (SinceTo.firstdate = Registros2.fecha) AND (SinceTo.ID = Registros2.ID);

  3. #3
    enroque is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    2
    Definitely, it works out! Thanks a lot, JoeM!

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are welcome. Glad I could help!

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

Similar Threads

  1. Replies: 5
    Last Post: 10-25-2017, 01:47 PM
  2. Replies: 9
    Last Post: 05-20-2016, 09:07 AM
  3. Replies: 4
    Last Post: 03-16-2016, 12:24 PM
  4. Replies: 2
    Last Post: 02-17-2014, 10:27 AM
  5. Replies: 9
    Last Post: 01-22-2013, 04:23 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