grogo21
asked on
Sql Syntax
Hello, I need to alter this portion:
Select count(LinkID) as Clicks, LinkID
from OutboundTraffic
group by LinkID
of the sql query i have below so that I can do a count of all records with the correct LinkID (as it does now) and also get a count of all records with the correct LinkID with a OutboundTraffic.ClickDate value = to todays date. Im not sure of the syntax required to make this work.
Thanks
Select count(LinkID) as Clicks, LinkID
from OutboundTraffic
group by LinkID
of the sql query i have below so that I can do a count of all records with the correct LinkID (as it does now) and also get a count of all records with the correct LinkID with a OutboundTraffic.ClickDate value = to todays date. Im not sure of the syntax required to make this work.
Thanks
SELECT
l.LinkID,
l.NavigateURL,
l.ImageFile,
l.Status,
isnull(l.StartDate, GetDate()) As StartDate,
isnull(u.rating,0) AS Rating,
isnull(o.Clicks,0) AS Clicks
FROM LinkIndex l
left join (
Select sum(rating) as Rating, LinkID
from UserRatings
group by LinkID
) u
on l.LinkID = u.LinkID
left join (
Select count(LinkID) as Clicks, LinkID
from OutboundTraffic
group by LinkID
) o
on l.LinkId = o.LinkId
where status in (0,1,2) and userid = 1001
order by startdate
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.