Commit 0335829
committed
Disambiguate ORDER BY in balance history DISTINCT ON
The SELECT aliased bucket_timestamp AS timestamp, so the secondary
ORDER BY timestamp DESC resolved to the alias (a constant within each
bucket) instead of the source row's timestamp. DISTINCT ON then picked
an arbitrary hour per day. Rename the underlying column to
source_timestamp in the CTE so the ORDER BY references it unambiguously
and end-of-day is selected.1 parent a836bcb commit 0335829
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
0 commit comments