postgresql - Using Convert on an ELSE CASE SQL query -
i performing sql query in postgres, selects numeric field. need display string value result of select, using case statement this:
select case numeric_field when 100 'some string' when 200 'some other string' the problem if numeric field has other value (like 300 example), need display value (as string of course). try put convert on else this
... else convert(varchar(10),numeric_field) but didn't work. how do this?
select case numeric_field when 100 'some string' when 200 'some other string' else numeric_field::text end result - your statement incomplete,
endmissing. read manual here. to output numeric field text, cast text:
numeric_field::text, postgres specific short form of sql standard call:cast (numeric_field text)
Comments
Post a Comment