CREATE TEMPORARY TABLE local AS SELECT row_number() over(order by grid_person_basic.office_community) `no`, grid_person_basic.office_community,kpi_office_grid_basic.office_community FROM grid_person_basic LEFT JOIN kpi_office_grid_basic ON grid_person_basic.office_community = kpi_office_grid_basic.office_community_id SELECT RIGHT(grid_person_basic.office_community(1), 1) as last_char, COUNT(*) as count, grid_person_basic.office_community,kpi_office_grid_basic.office_community, FROM local LEFT JOIN kpi_office_grid_basic ON grid_person_basic.office_community = kpi_office_grid_basic.office_community_id GROUP BY last_char; 代码哪里有错
时间: 2023-08-05 22:03:53 浏览: 102
IBM_AIX操作系统常见问题整理.pdf
在你提供的代码中,有几个问题需要修正:
1. 在第一条SELECT语句中,缺少了表格别名`grid_person_basic`。
2. 在第一条SELECT语句中,缺少了一个右括号`)`。
3. 在第一个SELECT语句的FROM子句中,没有包含临时表`local`。
4. 在第二个SELECT语句中,SELECT子句中引用了不存在的表格别名`grid_person_basic`。
5. 在第二个SELECT语句中,COUNT(*)后面多了一个逗号`,`。
下面是修正后的代码:
```sql
CREATE TEMPORARY TABLE local AS
SELECT row_number() over(order by grid_person_basic.office_community) `no`,
grid_person_basic.office_community,kpi_office_grid_basic.office_community
FROM grid_person_basic
LEFT JOIN kpi_office_grid_basic
ON grid_person_basic.office_community = kpi_office_grid_basic.office_community_id;
SELECT RIGHT(local.office_community, 1) as last_char, COUNT(*) as count,
local.office_community, kpi_office_grid_basic.office_community
FROM local
LEFT JOIN kpi_office_grid_basic
ON local.office_community = kpi_office_grid_basic.office_community_id
GROUP BY last_char;
```
请注意,我假设你已经创建了临时表`local`和相应的表格`grid_person_basic`和`kpi_office_grid_basic`存在,并且它们的列名和关联条件是正确的。如果代码还是有问题,请检查表格和列名是否正确,并根据实际情况进行调整。
阅读全文