I am trying to design a reporting service and some of the queries are not correctly constructed.
1 - select the top 50 terms that produce the most results for today:
2 - select the top 50 terms that produce the least results for today:
3 - select the top 10 terms with most results for the last 10 days
Table A
clientId searchterm count dateadded
0001 ping 5000 2011-05-15 12:00:00 00
This is what I have for 3:
Code:with tmp as( select clientid, searchterm, count(1) as TermResults, DENSE_RANK() OVER (partition by clientid ORDER BY clientId, count(1) DESC) as rnk from TFeed where dateadded >getdate() - 10 and not searchterm is null group by clientId, searchterm) select * from tmp where rnk < 11


Reply With Quote