I have created this query:
SELECT table1.id, b.sum FROM table1 CROSS JOIN (SELECT SUM(id) sum FROM table1) b ORDER BY id DESC;
But this will produce the following results:
id | sum |
---|---|
3 | 6 |
2 | 6 |
1 | 6 |
Sum value is printed only once. can you help me solve it.
But I want this result:
id | sum |
---|---|
3 | 6 |
2 | |
1 |
This should do the trick:
For more information, please see: Window function concepts and syntax