I’ve been working on a project that includes lots of summary statistics. One thing that would be very helpful for me would be to have a variable set equal to the result of a query that appeared on every line. Something like
declare @totalpop int
set @totalpop = select count(*) as [population]
from myTable
select sex, count(sex), @totalpop
from myTable
ninja edit on the query i tried, but it failed. Error is incorrect syntax near the keyword select
Based on your last paragraph, this seems to be what you want:
The expression with the “over” clause is a window function that adds up all the windows.