[英]Incorrect Syntax near the keyword On
I'm trying to make a query at work in which I count all occurrences of an id in one table and then I link the description and the colors associated with those ids from another. 我试图在工作中进行查询,在该查询中我统计一个表中所有ID的出现次数,然后将描述和与这些ID相关的颜色链接到另一个表中。
But I seem to have botched up my SQL Syntax (it's been a while, sorry!). 但是我似乎已经提高了我的SQL语法(已经有一段时间了,对不起!)。 It's probably just a silly mistake and I'd be so greatful to whoever could help me out!
这可能只是一个愚蠢的错误,对于任何可以帮助我的人,我都会非常感激!
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
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
Just remove unnecessary brackets (
and )
around inner join: 只需删除内部联接周围不必要的括号
(
和)
:
SELECT ....
FROM
dbo.Activity t1
INNER JOIN dbo.Activity_Status t2 ON t1.activity_status_id = t2.id
GROUP BY ....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.