FIREBIRD SELECT GREATEST lazarus / 16-Databases ---------------------------------------------------------------------- jack · 2012-02-29 15:01 I am trying to create a query using Select Greatest but I get an error "Unexpected end of command" at the last character of my command.  Is there some unique syntax to Firebird? example: SELECT GREATEST (1,2,3,4,5); Should Return 5 This is often given as the example for this command in other DBMS docs. Thanks for your help. ---------------------------------------------------------------------- Tankard · 2012-02-29 15:20 select max (1,2,3,4,5); ---------------------------------------------------------------------- jack · 2012-02-29 16:01 Here is the less trivial problem that I am trying to solve. I want to find the greater of the state or federal minimum wage on the date for which the payroll is being calculated. ======================================== SELECT GREATEST( (SELECT FMW_AMOUNT FROM FED_MIN_WAGE WHERE FMW_DATE = (SELECT MAX(FMW_DATE) from FED_MIN_WAGE WHERE FMW_DATE < current_date)) , (SELECT SMW_AMOUNT FROM STATE_MIN_WAGE WHERE SMW_DATE = (SELECT MAX(SMW_DATE) from STATE_MIN_WAGE WHERE SMW_DATE < current_date)) ) =================================================== Again thanks for your reply but MAX does not work here either. I have tried running quires on other simple examples and get same error, unexpected end of command. e.g. maxvalue(1,2,3,4); also fails. ---------------------------------------------------------------------- fredycc · 2012-02-29 17:20 Maybe this works in your case: Select maxvalue(1,2,3,4,5) As GREATEST from RDB$DATABASE Regards ---------------------------------------------------------------------- jack · 2012-02-29 19:24 Indeed it does work, Thank you. I shall endeavor to understand why it works at a later time.