I have this SQL
DECLARE @url varchar(100)
SET @url = 'http://mysite.com/%'
SELECT
[UserSessionSequenceID]
,[SiteID]
,[Referer]
,[Timestamp]
,ROW_NUMBER() over (PARTITION BY [Referer] ORDER BY referer DESC) AS sort
FROM [tblSequence]
WHERE [Referer] IS NOT NULL AND [Referer] NOT LIKE @url AND siteID = 15
Want to count unique referer - problem is that this SQL returns ALL matches and count those one by one. I only want the count for each unique referer (and still exsluding the @url with like).
How to do that?
SELECT
[Referer], Count([Referer]) as RefCount
FROM [tblSequence]
WHERE [Referer] IS NOT NULL AND [Referer] NOT LIKE @url AND siteID = 15
GROUP BY [Referer]
Putting Order back in (should that really be required) depends on your exact requirements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With