我正在尝试在工作中进行查询,在其中我计算一个表中所有出现的id,然后将描述和与这些ID相关联的颜色从另一个表中链接。
但我似乎搞砸了我的SQL语法(已经有一段时间了,抱歉!)。这可能只是一个愚蠢的错误,无论谁能帮助我,我都会非常感激!
SELECT
t1.activity_status_id,
count(*),
t2.description,
t2.color
FROM
dbo.Activity t1
INNER JOIN (
dbo.Activity_Status t2 ON t1.activity_status_id = t2.id)
GROUP BY
activity_status_id
答案 0 :(得分:2)
SELECT t1.activity_status_id,
Count(*),
t2.description,
t2.color
FROM dbo.Activity t1
INNER JOIN dbo.Activity_Status t2
ON t1.activity_status_id = t2.id
GROUP BY t1.activity_status_id ,t2.description,t2.color
答案 1 :(得分:2)
只需删除内部联接周围不必要的括号(
和)
:
SELECT ....
FROM
dbo.Activity t1
INNER JOIN dbo.Activity_Status t2 ON t1.activity_status_id = t2.id
GROUP BY ....