Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    1

    Unanswered: Sql statement in access database

    I am trying to figure how to get the ORDER BY part of the below statement to work. Without the ORDER BY statement everything works correctly. But with it I get this error. Can anybody give me some feedback. Thanks.

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.


    SQLString = "SELECT zip_code, zipcode_latitude, zipcode_longitude, zip_class, zipcode_poname, zipcode_state, zipcode_county, (SIN("& iStartLat &"/57.2958) * SIN(zipcode_latitude/57.2958)) + (COS("& iStartLat &"/57.2958) * COS(zipcode_latitude/57.2958) * COS(zipcode_longitude/57.2958 - "& iStartLong &"/57.2958)) AS var1, (atn((sqr(1-var1^2))/var1)) AS var2, (1.852 * 60.0 * ((var2/"& pi &")*180)/ 1.609344) AS distance FROM zipcodes WHERE zipcode_Latitude <= " & HighLatitude & " AND zipcode_Latitude >= " & LowLatitude & " AND zipcode_longitude >= " & LowLongitude & " AND zipcode_longitude <= " & HighLongitude &" ORDER BY distance"

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    sadly, you cannot ORDER BY a column alias in microsoft access

    either repeat the expression, or use an ordinal number

    in your case, ORDER BY 10
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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