Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.0.4
-
None
Description
With the following table:
create table opportunities (id int, accountName varchar(20), name varchar(128), owner varchar(7), amount decimal(10,2), closeDate date, stageName varchar(11)) engine=columnstore;
|
the window query below which should in theory work gives wrong results for pct_won:
select owner, count(*) wins, count(*) /( sum(count(*)) over ()) pct_won from opportunities group by 1;
|
Rewriting the query to have the window function isolated in a subquery works around the issue:
select t.owner, t.wins, t.wins / t.total pct_won from (select owner, count(*) wins, sum(count(*)) over () total from opportunities group by 1) t;
|