3 Replies Latest reply on Feb 21, 2007 9:26 AM by Newsgroup_User

    MAX Function

    sargent_slaughter
      I am getting a sytax error using MAX function on a column
      <CFQUERY NAME="getId" DATASOURCE="lvdining">
      SELECT MAX(updatedId) AS max_date,
      From list_update
      </CFQUERY>
      I have tried just about every form I have found of the MAX() function and I get the same sytax error
      SQL SELECT MAX(updatedId) AS max_date, From list_update
      DATASOURCE lvdining
      VENDORERRORCODE -3504
      SQLSTATE 42000
        • 1. Re: MAX Function
          Dan Bracuk Level 5
          Take away the comma after max_date
          • 2. Re: MAX Function
            sargent_slaughter Level 1
            Removing just gave a new error

            Error Executing Database Query.
            [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

            The error occurred in D:\INETPUB\dineamerica\lasvegas\test_date.cfm: line 9

            7 : </CFQUERY>
            8 :
            9 : <CFQUERY NAME="getId" DATASOURCE="lvdining">
            10 : SELECT MAX(update) AS max_date
            11 : From list_update



            --------------------------------------------------------------------------------

            SQL SELECT MAX(update) AS max_date From list_update
            DATASOURCE lvdining
            VENDORERRORCODE -3010
            SQLSTATE 07002

            • 3. Re: MAX Function
              Level 7
              sargent_slaughter wrote:

              > 9 : <CFQUERY NAME="getId" DATASOURCE="lvdining">
              > 10 : SELECT MAX(update) AS max_date
              > 11 : From list_update

              it is not a good practice to use reserved words for table/field names.
              UPDATE is an SQL reserved word.
              i do not remember what exactly you can do short of renaming your field
              to something else (i.e. updated instead of update). maybe try
              surrounding it with [], i.e. MAX([list_update].[update])...