Posted by Colin, Jan. 21, 2023, 10:41 p.m.
#100 shows different sample results than final results
Driving myself crazy on this one. The below query produces the same results as those shown in the "sample results."
SELECT
DISTINCT
advertiser_id,
(SUM(spend) OVER (PARTITION BY advertiser_id)
/
SUM(cost) OVER (PARTITION BY advertiser_id)) as roi
FROM advertiser a
LEFT JOIN ad_info ai ON a.ad_id = ai.ad_id
ORDER BY advertiser_id
Sample results:
advertiser_id | roi
---------------+--------------------
1 | 0.8095238095238095
2 | 0.511578947368421
My results:
| advertiser_id | roi |
|---|---|
| 1 | 0.8095238095238095 |
| 2 | 0.511578947368421 |
Yet these do not match the final results. Is this a bug? The logic of my query seems to track, and it does match the sample, so seems like something is off.