Is there any way to rank a dataset by the result of another window function?
For example, I have a query like this one below:
select distinct
country,
cast(sum(Sessions) over (partition by country) as float) / cast(sum(sessions) over() as float) as sess_prcnt
from
GoogleAnalytics.dbo.SiteVisitsLog
order by
sess_prcnt desc
What I want to do is to rank the countries by the sess_prcnt
column.
Adding a line like rank() over(order by sess_prcnt)
or using CTE gives errors.
Thank you in advance!