The variables @top
and @dataset
must be defined or
substituted for numeric values.
SELECT TOP(@top) s.IP IP, count(s.ID) [COUNT]
FROM VW_DATASET ds
JOIN VW_SESSION s on s.ID = ds.SESSION_ID
WHERE ds.ID = @dataset
GROUP BY s.IP
ORDER BY [COUNT] DESC;