select SUM(CASE WHEN MI_VALUE IS NULL THEN 1 WHEN MI_VALUE ='null' THEN 1 ELSE 0 END) SL from CPM_EM_MNTING_W where GX_TIME >= SYSDATE - 1 group by SUBSTR(MI_CODE,1,5),''
时间: 2024-04-13 13:31:04 浏览: 10
您好!根据您的查询需求,我可以帮您编写一个SQL查询语句。请注意,我将使用占位符来代替您提供的空白部分。以下是您的查询语句:
```sql
SELECT SUBSTR(MI_CODE, 1, 5) AS SUB_CODE, SUM(CASE WHEN MI_VALUE IS NULL THEN 1 WHEN MI_VALUE = 'null' THEN 1 ELSE 0 END) AS SL
FROM CPM_EM_MNTING_W
WHERE GX_TIME >= SYSDATE - 1
GROUP BY SUBSTR(MI_CODE, 1, 5)
```
请将占位符替换为适当的值,并在执行查询之前确保数据库连接和表结构的正确设置。如果您有任何进一步的问题,请随时提问!
相关问题
select case when null = null then 1 null <> null then 2 else 3 end result_value from dual;
执行这个 SQL 语句的结果是 3。这是因为在 SQL 中,NULL 值与任何值都不相等,包括 NULL 本身。因此,当执行 `null = null` 时,结果为未知(unknown),而不是 true 或 false,因此会跳过第一个 `when` 子句,执行第二个 `when` 子句。同样,当执行 `null <> null` 时,结果也是未知(unknown),因此会执行 `else` 子句,返回结果值 3。在 SQL 中,判断 NULL 值是否相等或不相等时,应该使用 `is null` 或 `is not null` 来判断,而不是使用 `=` 或 `<>` 运算符。
select case when null = null then 1 when null < > null then 2 else 3 end result_value from dual;
The result of this query would be 1.
Explanation:
- The first condition "null = null" is evaluated as true.
- The second condition "null < > null" is evaluated as null, because any comparison with null results in null.
- Since the second condition is not true, the query moves on to the "else" clause and returns 3.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)