This thread references thread183-1305249 which is now closed. It asked for help with an inner join and count. I am also looking for assistance.
Here is the original Thread Reponse that solved the problem and below is my code this is using this as an example, but not working.
My code below - I am trying to get the number of permits for each permitType
I encounter the following error:
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'ON'.
Jim Osieczonek
Delta Business Group, LLC
Here is the original Thread Reponse that solved the problem and below is my code this is using this as an example, but not working.
Code:
bborissov (Programmer) 24 Nov 06 2:52
You can't use c.count(*), the correct syntax is count(c.SomeField). Also when you have COUNT(), SUM() etc. you must have GROUP BY. But when you have GROUP BY you must include ALL fields which are not involved in agregate functions. So beeter try:
CODE
select A.*,
c.views,
B.Username
from video a
inner join user b on a.userid = b.userid
inner join (SELECT videoid, COUNT(*) AS Views
FROM video_view
GROUP BY videoid)c
on a.videoid = c.videoid
My code below - I am trying to get the number of permits for each permitType
Code:
select dbo.m_permitType.permittypeid, m_permitType.permitName from dbo.m_permitType
inner join (select dbo.permit.permitTypeId, COUNT(*) as PermitCount
FROM dbo.permit GROUP BY dbo.permit.permitTypeId) ON
dbo.Permit.permittypeid = dbo.m_permitType.permittypeid
I encounter the following error:
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'ON'.
Jim Osieczonek
Delta Business Group, LLC