请帮我优化这段sql,SELECT b.alert_description AS `key`,COUNT(a.alert_id) AS `value` FROM r_robot_alert a LEFT JOIN dim_alert_code b ON b.alert_type = a.alert_type WHERE a.customer_name LIKE '%%江西省肿瘤医院%%' AND dt BETWEEN '2022-10-16' AND '2022-12-16' AND alert_level = 'Error' GROUP BY alert_description
时间: 2023-02-06 16:25:20 浏览: 103
oracle_resource.rar_oracle_oracle_resource
这是您的 SQL 语句的优化版本:
```
SELECT b.alert_description AS `key`, COUNT(a.alert_id) AS `value`
FROM r_robot_alert a
LEFT JOIN dim_alert_code b ON b.alert_type = a.alert_type
WHERE a.customer_name LIKE '%%u6c5fu897fu7701u80bfu7624u533bu9662%%'
AND dt BETWEEN '2022-10-16' AND '2022-12-16'
AND alert_level = 'Error'
GROUP BY b.alert_description
```
注意:
- WHERE 子句中的 `a.customer_name` 和 `alert_level` 应该用单引号引用字符串值。
- BETWEEN 子句中的日期应该用单引号引用。
希望这可以帮到您!
阅读全文