sum(CASE WHEN ( ( (regexp_like(CSRQ, '^[0-9]+$')) AND ( substr(CSRQ, 1, 4) > '1900' AND substr(CSRQ, 1, 4) < '2300' AND substr(CSRQ, 5, 2) BETWEEN '01' AND '12' AND substr(CSRQ, 7, 2) BETWEEN '01' AND '31' ) ) or CSRQ IS NULL ) THEN 1 ELSE 0 END) 这段代码转成sqlserver
时间: 2023-08-10 21:05:59 浏览: 244
SQL SUM() 函数
以下是将该代码转换为SQL Server的语法:
```
SUM(CASE
WHEN ((ISNULL(CSRQ,'') = '') OR (ISNUMERIC(CSRQ) = 1 AND SUBSTRING(CSRQ, 1, 4) > '1900' AND SUBSTRING(CSRQ, 1, 4) < '2300' AND SUBSTRING(CSRQ, 5, 2) BETWEEN '01' AND '12' AND SUBSTRING(CSRQ, 7, 2) BETWEEN '01' AND '31'))
THEN 1
ELSE 0
END)
```
在 SQL Server 中,使用 `ISNUMERIC()` 函数来检查一个字符串是否为数字。此外,使用 `ISNULL()` 函数来检查一个值是否为 NULL,其语法为 `ISNULL(expression, value_if_expression_is_null)`。
阅读全文