Error "SQL command not properly ended" when using "order by" clause and "use last run datetime" fieldIssue When customer using JDBC datasources, configure a SQL query to run on the Source DB Server. In this SQL query if customer has Order By clause, there are following scenarios. 1. When Checkbox for Use Lastrun datetime is set to False 2. When Checkbox for Use Lastrun datetime is set to True In Scenario 1 there is no issue observed. In Scenario 2 when User Last run datetime is set to True and customer also uses Order By clause in the SQL query, it throws an error - "SQL command not properly ended".CauseWhen we run the datasource (Order By clause in SQL Statement and User Last run DateTime option set to true), system appends Order By '<Last_run_datetime field> clause at the end of the sql statement. Causing 2 Order By clause. e.g - if original sql statement with order by clause is - SELECTCUR.ISO_CODE,EX.SDL_ID,EX.FACTOR / USD.FACTOR AS FACTOR_USD,EX.ACTIVE_FROM_DATE ,EX.ACTIVE_TO_DATE,to_char(EX.MDM_INTERFACE_UPDATE_TIMESTAMP) as LAST_UPDATE,EX.MDM_INTERFACE_UPDATE_TIMESTAMPFROM MDM.MV_CUR_CURRENCY CUR,MDM.MV_CUR_EXCHANGE_RATE EX,(SELECT BASE_CURRENCY_SDL_ID,EX.ACTIVE_FROM_DATE,EX.ACTIVE_TO_DATE,FACTORFROM MDM.MV_CUR_EXCHANGE_RATE EX, MDM.MV_CUR_CURRENCY CURWHERE EX.BASE_CURRENCY_SDL_ID = CUR.SDL_IDAND CUR.ISO_CODE = 'USD'AND EXCHANGE_RATE_TYPE_CODE = 'QQ') USDWHERE CUR.SDL_ID = EX.BASE_CURRENCY_SDL_IDAND EX.ACTIVE_FROM_DATE = USD.ACTIVE_FROM_DATEAND EX.ACTIVE_TO_DATE = USD.ACTIVE_TO_DATEAND EX.EXCHANGE_RATE_TYPE_CODE = 'QQ'AND EX.MDM_INTERFACE_UPDATE_TIMESTAMP >= '30-JUN-20 01.00.36.000000 AM'ORDER BY EX.MDM_INTERFACE_UPDATE_TIMESTAMP ASC Then SQL statement resulting due to Use Last run datetime is - SELECTCUR.ISO_CODE,EX.SDL_ID,EX.FACTOR / USD.FACTOR AS FACTOR_USD,EX.ACTIVE_FROM_DATE ,EX.ACTIVE_TO_DATE,to_char(EX.MDM_INTERFACE_UPDATE_TIMESTAMP) as LAST_UPDATE,EX.MDM_INTERFACE_UPDATE_TIMESTAMPFROM MDM.MV_CUR_CURRENCY CUR,MDM.MV_CUR_EXCHANGE_RATE EX,(SELECT BASE_CURRENCY_SDL_ID,EX.ACTIVE_FROM_DATE,EX.ACTIVE_TO_DATE,FACTORFROM MDM.MV_CUR_EXCHANGE_RATE EX, MDM.MV_CUR_CURRENCY CURWHERE EX.BASE_CURRENCY_SDL_ID = CUR.SDL_IDAND CUR.ISO_CODE = 'USD'AND EXCHANGE_RATE_TYPE_CODE = 'QQ') USDWHERE CUR.SDL_ID = EX.BASE_CURRENCY_SDL_IDAND EX.ACTIVE_FROM_DATE = USD.ACTIVE_FROM_DATEAND EX.ACTIVE_TO_DATE = USD.ACTIVE_TO_DATEAND EX.EXCHANGE_RATE_TYPE_CODE = 'QQ'AND EX.MDM_INTERFACE_UPDATE_TIMESTAMP >= '30-JUN-20 01.00.36.000000 AM'ORDER BY EX.MDM_INTERFACE_UPDATE_TIMESTAMP ASCORDER BY <Last_run_datetime_time> The 2 ORDER BY clauses in the SQL statement cause an error - SQL command not properly ended".ResolutionUsers don't really need to add Order By clause to the SQL Statement, as when you run the Load All Data, backend code appends the ORDER BY <Last_run_datetime_field> clause to the end of SQL Statement by default. Please note - Running Load 20 records doesn't add the ORDER BY clause to the SQL statement. So to the crux of it, Using ORDER BY clause to the SQL statement + Use of "Use last run datetime" is not possible.