grogo21
asked on
Sql Syntax Joins
Hello, I was wondering how I can modify the sql query I have below so that instead of setting @StatCode manully each time It would select all of the StatCodes in a table and complete the operation below for each one.
The table and field which contains the StatCode values is StatSource.StatCode. I tried to do this myself but was unable to work through it. Hopefully after I see it done one more time i will be able to do it myself!
Thanks!
The table and field which contains the StatCode values is StatSource.StatCode. I tried to do this myself but was unable to work through it. Hopefully after I see it done one more time i will be able to do it myself!
Thanks!
Declare @StatCode int
Set @StatCode = 8
select COUNT(VisitorID) As Clicks, COUNT(Distinct(VisitorID)) As UniqueVisitors
from outboundtraffic
where VisitorID in(Select VisitorID from InboundTraffic where StatCode = @StatCode)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
from outboundtraffic a, InboundTraffic b, StatSource c
WHERE a.VisitorID = b.VisitorID
AND b.StatCode = c.StatCode
GROUP BY b.StatCode