| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|||
SELECT T2.WEEK, T2.TOTAL, COALESCE(SUM(T1.TOTAL), 0) AS THere I use the COALESCE function that will replace the NULL that can be found in some rows by 0 (otherwise the sum couldn't be done) |
|
|||
|
Nearly the same but last column is current total + previous like :
week total t 1 5 5 2 6 11 3 5 16
SELECT t2.week, t2.total, sum(t1.total) |
|
|||
|
The following feature outside Core SQL-99 is used:
T611, "Elementary OLAP operations" (checked with the mimer sql validator)
SELECT week |
![]() |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|