Reputation: 5709
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.
But I seem to have botched up my SQL Syntax (it's been a while, sorry!). 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
Upvotes: 0
Views: 17104
Reputation: 574
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
Upvotes: 2
Reputation: 26846
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 ....
Upvotes: 3