Answer the question
In order to leave comments, you need to log in
How to use if in postgres?
SELECT "F_TagName_ID",
"F_Date",
"F_ConvertedValue",
IF (8 < to_char("F_Date", 'H24')::int
AND to_char("F_Date", 'H24')::int < 20) THEN RETURN 2 AS smena ; ELSE RETURN 1 AS smena;
END IF;
FROM "SC_Tag"."T_TagData"
Answer the question
In order to leave comments, you need to log in
Use CASE
Something like this:
SELECT "F_TagName_ID",
"F_Date",
"F_ConvertedValue",
CASE WHEN (8 < to_char("F_Date", 'H24')::int
AND to_char("F_Date", 'H24')::int < 20) THEN 2 ELSE 1 END AS smena
FROM "SC_Tag"."T_TagData"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question