Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Location
    California
    Posts
    502

    Unanswered: Syntax error (missing operator) in query expression

    This worked with just one city, however I need to be able to place multiple city abbreviations (as many as 15 sometimes) in this query. Wow-it would be great if I could sum the count number for each city?

    Code:
    SELECT TblCRMLS_CLOSED_STATS.City, TblCRMLS_CLOSED_STATS.DateClosedSale, TblCRMLS_CLOSED_STATS.ListPriceOriginal, TblCRMLS_CLOSED_STATS.ListPriceLow, TblCRMLS_CLOSED_STATS.SellingPrice
    FROM TblCRMLS_CLOSED_STATS
    WHERE (((TblCRMLS_CLOSED_STATS.City)="cdm" OR (TblCRMLS_CLOSED_STATS.City)="cdc" AND ([TblCRMLS_CLOSED_STATS.ListPriceOriginal])>[TblCRMLS_CLOSED_STATS.SellingPrice]))
    GROUPBY TblCRMLS_CLOSED_STATS.City)ASC;
    Thanks much . . . Rick
    Last edited by Missinglinq; 02-10-15 at 21:54. Reason: Correcting 'code' formatting.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Be wary of brackets...
    ...not least because the Access query designer loves them to bits and inserts thrm willy nilly making the sql look more complex than it is.
    Having said that I suspect your syntax error is probably an extra ) in the group by clause.
    your where clause indicates to me you dont seem to have grasped the purpose of the brackets. Use them to group together or isolate logical expressions. What i think you want is (city = cdm or city = cdc) and listprice > Sellingprice
    If you want multiple examples of the same column then consider using the in construct
    Code:
    where city in ('cdm', 'cdc') and......
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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