SELECT SUM(t1.fkds) AS fkdss , t2.cght as htid FROM uf_cgfksjb_dt2 t1 INNER JOIN uf_cgfksjb t2 on t1.mainid=t2.id group by fkdss htid哪里错 了,怎么改
时间: 2024-03-27 16:40:08 浏览: 132
这条 SQL 语句有两个问题:
1. `group by` 后面应该跟上 `htid` 和 `fkdss`,而不是 `fkdss htid`。
2. `fkdss` 是一个别名,应该使用原始的字段名 `t1.fkds`。
下面是修改后的 SQL 语句:
```
SELECT SUM(t1.fkds) AS fkdss, t2.cght AS htid
FROM uf_cgfksjb_dt2 t1
INNER JOIN uf_cgfksjb t2 ON t1.mainid = t2.id
GROUP BY htid, fkdss
```
阅读全文