SQL functions in proper format