I apologize if this question has been asked before, but I get a timed out response when searching the database so this is my last resort.
I am trying to build an SQL query that will return data to be displayed/accessed via ADO in an application. Basically, the result should show cummulative counts and percentages. Here is the basic SQL where I am starting.
SELECT distinct var1,
count(var1) as [Count],
CONVERT(decimal,COUNT(var1)) / 690 as [PCT]
GROUP BY var1
My thought is to modify this statement to use a local declare variable. I can't seem to figure out how to:
1.) set the value of the local variable say @cumpct = @cumpct + [pct]
2.) load the value of @cumpct into a new field in the query such as @cumpct as [Cum Pct]
If I can figure out this problem, I will have the answer to multiple other hacked workarounds I have used in the past.