[英]Convert T-SQL using IF to Postgres
IF NULLIF(@date, '') IS NULL
select * from [dbo].[SRC_DSSI_OPER_STAT]
else
select * from [dbo].[SRC_DSSI_OPER_STAT] where CONVERT(DATE, (shift_start_date)) = CONVERT(DATE, @date - 1)
How can i convert this T-sql code to PostgreSQL 我如何将此T-sql代码转换为PostgreSQL
Supposing @date is a string, in postgresql I will call it input_date 假设@date是一个字符串,在PostgreSQL中,我将其称为input_date
IF input_date = '' THEN
select * from "SRC_DSSI_OPER_STAT";
ELSE
select * from "SRC_DSSI_OPER_STAT" where shift_start_date::date = input_date - interval '1' day;
END IF;
You can have problems about your date format, in that case you must working more on date conversions. 您可能会遇到日期格式方面的问题,在这种情况下,您必须更多地处理日期转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.