WITHOUT ANALYTIC CLAUSE
select department_id, salary, sum(salary) over () as "Overall salary total"
from hr.employees
DEPARTMENT_ID | SALARY | Overall salary total | 90 | 24000 | 691416 | 90 | 17000 | 691416 | 90 | 17000 | 691416 | 60 | 9000 | 691416 | 60 | 6000 | 691416 | 60 | 4800 | 691416 | 60 | 4800 | 691416 | 60 | 4200 | 691416 | 100 | 12008 | 691416 | 100 | 9000 | 691416 | 100 | 8200 | 691416 | 100 | 7700 | 691416 | 100 | 7800 | 691416 | 100 | 6900 | 691416 | 30 | 11000 | 691416 | 30 | 3100 | 691416 | 30 | 2900 | 691416 | 30 | 2800 | 691416 | 30 | 2600 | 691416 | 30 | 2500 | 691416 | 50 | 8000 | 691416 | 50 | 8200 | 691416 | 50 | 7900 | 691416 | 50 | 6500 | 691416 | 50 | 5800 | 691416 | 50 | 3200 | 691416 | 50 | 2700 | 691416 | 50 | 2400 | 691416 | 50 | 2200 | 691416 | 50 | 3300 | 691416 | 50 | 2800 | 691416 | 50 | 2500 | 691416 | 50 | 2100 | 691416 | 50 | 3300 | 691416 | 50 | 2900 | 691416 | 50 | 2400 | 691416 | 50 | 2200 | 691416 | 50 | 3600 | 691416 | 50 | 3200 | 691416 | 50 | 2700 | 691416 | 50 | 2500 | 691416 | 50 | 3500 | 691416 | 50 | 3100 | 691416 | 50 | 2600 | 691416 | 50 | 2500 | 691416 | 80 | 14000 | 691416 | 80 | 13500 | 691416 | 80 | 12000 | 691416 | 80 | 11000 | 691416 | 80 | 10500 | 691416 | 80 | 10000 | 691416 | 80 | 9500 | 691416 | 80 | 9000 | 691416 | 80 | 8000 | 691416 | 80 | 7500 | 691416 | 80 | 7000 | 691416 | 80 | 10000 | 691416 | 80 | 9500 | 691416 | 80 | 9000 | 691416 | 80 | 8000 | 691416 | 80 | 7500 | 691416 | 80 | 7000 | 691416 | 80 | 10500 | 691416 | 80 | 9500 | 691416 | 80 | 7200 | 691416 | 80 | 6800 | 691416 | 80 | 6400 | 691416 | 80 | 6200 | 691416 | 80 | 11500 | 691416 | 80 | 10000 | 691416 | 80 | 9600 | 691416 | 80 | 7400 | 691416 | 80 | 7300 | 691416 | 80 | 6100 | 691416 | 80 | 11000 | 691416 | 80 | 8800 | 691416 | 80 | 8600 | 691416 | 80 | 8400 | 691416 | - | 7000 | 691416 | 80 | 6200 | 691416 | 50 | 3200 | 691416 | 50 | 3100 | 691416 | 50 | 2500 | 691416 | 50 | 2800 | 691416 | 50 | 4200 | 691416 | 50 | 4100 | 691416 | 50 | 3400 | 691416 | 50 | 3000 | 691416 | 50 | 3800 | 691416 | 50 | 3600 | 691416 | 50 | 2900 | 691416 | 50 | 2500 | 691416 | 50 | 4000 | 691416 | 50 | 3900 | 691416 | 50 | 3200 | 691416 | 50 | 2800 | 691416 | 50 | 3100 | 691416 | 50 | 3000 | 691416 | 50 | 2600 | 691416 | 50 | 2600 | 691416 | 10 | 4400 | 691416 | 20 | 13000 | 691416 | 20 | 6000 | 691416 | 40 | 6500 | 691416 | 70 | 10000 | 691416 | 110 | 12008 | 691416 | 110 | 8300 | 691416 |
---|
PARTITION BY CLAUSE
select department_id, salary, sum(salary) over (partition by department_id) as "Department salary total"
from hr.employees
DEPARTMENT_ID | SALARY | Department salary total | 10 | 4400 | 4400 | 20 | 13000 | 19000 | 20 | 6000 | 19000 | 30 | 11000 | 24900 | 30 | 3100 | 24900 | 30 | 2900 | 24900 | 30 | 2800 | 24900 | 30 | 2600 | 24900 | 30 | 2500 | 24900 | 40 | 6500 | 6500 | 50 | 8000 | 156400 | 50 | 8200 | 156400 | 50 | 7900 | 156400 | 50 | 6500 | 156400 | 50 | 5800 | 156400 | 50 | 3200 | 156400 | 50 | 2700 | 156400 | 50 | 2400 | 156400 | 50 | 2200 | 156400 | 50 | 3300 | 156400 | 50 | 2800 | 156400 | 50 | 2500 | 156400 | 50 | 2100 | 156400 | 50 | 3300 | 156400 | 50 | 2900 | 156400 | 50 | 2400 | 156400 | 50 | 2200 | 156400 | 50 | 3600 | 156400 | 50 | 3200 | 156400 | 50 | 2700 | 156400 | 50 | 2500 | 156400 | 50 | 3500 | 156400 | 50 | 3100 | 156400 | 50 | 2600 | 156400 | 50 | 2500 | 156400 | 50 | 3200 | 156400 | 50 | 3100 | 156400 | 50 | 2500 | 156400 | 50 | 2800 | 156400 | 50 | 4200 | 156400 | 50 | 4100 | 156400 | 50 | 3400 | 156400 | 50 | 3000 | 156400 | 50 | 3800 | 156400 | 50 | 3600 | 156400 | 50 | 2900 | 156400 | 50 | 2500 | 156400 | 50 | 4000 | 156400 | 50 | 3900 | 156400 | 50 | 3200 | 156400 | 50 | 2800 | 156400 | 50 | 3100 | 156400 | 50 | 3000 | 156400 | 50 | 2600 | 156400 | 50 | 2600 | 156400 | 60 | 9000 | 28800 | 60 | 6000 | 28800 | 60 | 4800 | 28800 | 60 | 4800 | 28800 | 60 | 4200 | 28800 | 70 | 10000 | 10000 | 80 | 14000 | 304500 | 80 | 13500 | 304500 | 80 | 12000 | 304500 | 80 | 11000 | 304500 | 80 | 10500 | 304500 | 80 | 10000 | 304500 | 80 | 9500 | 304500 | 80 | 9000 | 304500 | 80 | 8000 | 304500 | 80 | 7500 | 304500 | 80 | 7000 | 304500 | 80 | 10000 | 304500 | 80 | 9500 | 304500 | 80 | 9000 | 304500 | 80 | 8000 | 304500 | 80 | 7500 | 304500 | 80 | 7000 | 304500 | 80 | 10500 | 304500 | 80 | 9500 | 304500 | 80 | 7200 | 304500 | 80 | 6800 | 304500 | 80 | 6400 | 304500 | 80 | 6200 | 304500 | 80 | 11500 | 304500 | 80 | 10000 | 304500 | 80 | 9600 | 304500 | 80 | 7400 | 304500 | 80 | 7300 | 304500 | 80 | 6100 | 304500 | 80 | 11000 | 304500 | 80 | 8800 | 304500 | 80 | 8600 | 304500 | 80 | 8400 | 304500 | 80 | 6200 | 304500 | 90 | 24000 | 58000 | 90 | 17000 | 58000 | 90 | 17000 | 58000 | 100 | 12008 | 51608 | 100 | 9000 | 51608 | 100 | 8200 | 51608 | 100 | 7700 | 51608 | 100 | 7800 | 51608 | 100 | 6900 | 51608 | 110 | 12008 | 20308 | 110 | 8300 | 20308 | - | 7000 | 7000 |
---|
PARTTION BY CLAUSE & ORDER BY CLAUSE
select department_id, last_name, first_name, salary, sum(salary) over (partition by department_id order by last_name, first_name) as "Cumulative salary total"
from hr.employees
DEPARTMENT_ID | LAST_NAME | FIRST_NAME | SALARY | Cumulative salary total | 10 | Whalen | Jennifer | 4400 | 4400 | 20 | Fay | Pat | 6000 | 6000 | 20 | Hartstein | Michael | 13000 | 19000 | 30 | Baida | Shelli | 2900 | 2900 | 30 | Colmenares | Karen | 2500 | 5400 | 30 | Himuro | Guy | 2600 | 8000 | 30 | Khoo | Alexander | 3100 | 11100 | 30 | Raphaely | Den | 11000 | 22100 | 30 | Tobias | Sigal | 2800 | 24900 | 40 | Mavris | Susan | 6500 | 6500 | 50 | Atkinson | Mozhe | 2800 | 2800 | 50 | Bell | Sarah | 4000 | 6800 | 50 | Bissot | Laura | 3300 | 10100 | 50 | Bull | Alexis | 4100 | 14200 | 50 | Cabrio | Anthony | 3000 | 17200 | 50 | Chung | Kelly | 3800 | 21000 | 50 | Davies | Curtis | 3100 | 24100 | 50 | Dellinger | Julia | 3400 | 27500 | 50 | Dilly | Jennifer | 3600 | 31100 | 50 | Everett | Britney | 3900 | 35000 | 50 | Feeney | Kevin | 3000 | 38000 | 50 | Fleaur | Jean | 3100 | 41100 | 50 | Fripp | Adam | 8200 | 49300 | 50 | Gates | Timothy | 2900 | 52200 | 50 | Gee | Ki | 2400 | 54600 | 50 | Geoni | Girard | 2800 | 57400 | 50 | Grant | Douglas | 2600 | 60000 | 50 | Jones | Vance | 2800 | 62800 | 50 | Kaufling | Payam | 7900 | 70700 | 50 | Ladwig | Renske | 3600 | 74300 | 50 | Landry | James | 2400 | 76700 | 50 | Mallin | Jason | 3300 | 80000 | 50 | Markle | Steven | 2200 | 82200 | 50 | Marlow | James | 2500 | 84700 | 50 | Matos | Randall | 2600 | 87300 | 50 | McCain | Samuel | 3200 | 90500 | 50 | Mikkilineni | Irene | 2700 | 93200 | 50 | Mourgos | Kevin | 5800 | 99000 | 50 | Nayer | Julia | 3200 | 102200 | 50 | OConnell | Donald | 2600 | 104800 | 50 | Olson | TJ | 2100 | 106900 | 50 | Patel | Joshua | 2500 | 109400 | 50 | Perkins | Randall | 2500 | 111900 | 50 | Philtanker | Hazel | 2200 | 114100 | 50 | Rajs | Trenna | 3500 | 117600 | 50 | Rogers | Michael | 2900 | 120500 | 50 | Sarchand | Nandita | 4200 | 124700 | 50 | Seo | John | 2700 | 127400 | 50 | Stiles | Stephen | 3200 | 130600 | 50 | Sullivan | Martha | 2500 | 133100 | 50 | Taylor | Winston | 3200 | 136300 | 50 | Vargas | Peter | 2500 | 138800 | 50 | Vollman | Shanta | 6500 | 145300 | 50 | Walsh | Alana | 3100 | 148400 | 50 | Weiss | Matthew | 8000 | 156400 | 60 | Austin | David | 4800 | 4800 | 60 | Ernst | Bruce | 6000 | 10800 | 60 | Hunold | Alexander | 9000 | 19800 | 60 | Lorentz | Diana | 4200 | 24000 | 60 | Pataballa | Valli | 4800 | 28800 | 70 | Baer | Hermann | 10000 | 10000 | 80 | Abel | Ellen | 11000 | 11000 | 80 | Ande | Sundar | 6400 | 17400 | 80 | Banda | Amit | 6200 | 23600 | 80 | Bates | Elizabeth | 7300 | 30900 | 80 | Bernstein | David | 9500 | 40400 | 80 | Bloom | Harrison | 10000 | 50400 | 80 | Cambrault | Gerald | 11000 | 61400 | 80 | Cambrault | Nanette | 7500 | 68900 | 80 | Doran | Louise | 7500 | 76400 | 80 | Errazuriz | Alberto | 12000 | 88400 | 80 | Fox | Tayler | 9600 | 98000 | 80 | Greene | Danielle | 9500 | 107500 | 80 | Hall | Peter | 9000 | 116500 | 80 | Hutton | Alyssa | 8800 | 125300 | 80 | Johnson | Charles | 6200 | 131500 | 80 | King | Janette | 10000 | 141500 | 80 | Kumar | Sundita | 6100 | 147600 | 80 | Lee | David | 6800 | 154400 | 80 | Livingston | Jack | 8400 | 162800 | 80 | Marvins | Mattea | 7200 | 170000 | 80 | McEwen | Allan | 9000 | 179000 | 80 | Olsen | Christopher | 8000 | 187000 | 80 | Ozer | Lisa | 11500 | 198500 | 80 | Partners | Karen | 13500 | 212000 | 80 | Russell | John | 14000 | 226000 | 80 | Sewall | Sarath | 7000 | 233000 | 80 | Smith | Lindsey | 8000 | 241000 | 80 | Smith | William | 7400 | 248400 | 80 | Sully | Patrick | 9500 | 257900 | 80 | Taylor | Jonathon | 8600 | 266500 | 80 | Tucker | Peter | 10000 | 276500 | 80 | Tuvault | Oliver | 7000 | 283500 | 80 | Vishney | Clara | 10500 | 294000 | 80 | Zlotkey | Eleni | 10500 | 304500 | 90 | De Haan | Lex | 17000 | 17000 | 90 | King | Steven | 24000 | 41000 | 90 | Kochhar | Neena | 17000 | 58000 | 100 | Chen | John | 8200 | 8200 | 100 | Faviet | Daniel | 9000 | 17200 | 100 | Greenberg | Nancy | 12008 | 29208 | 100 | Popp | Luis | 6900 | 36108 | 100 | Sciarra | Ismael | 7700 | 43808 | 100 | Urman | Jose Manuel | 7800 | 51608 | 110 | Gietz | William | 8300 | 8300 | 110 | Higgins | Shelley | 12008 | 20308 | - | Grant | Kimberely | 7000 | 7000 |
---|
PARTITION BY CLAUSE, ORDER BY CLAUSE & WINDOWING CLAUSE
select department_id, last_name, first_name, salary, sum(salary) over (partition by department_id order by last_name, first_name rows 2 preceding) as "Only add preceding two"
from hr.employees
DEPARTMENT_ID | LAST_NAME | FIRST_NAME | SALARY | Only add preceding two | 10 | Whalen | Jennifer | 4400 | 4400 | 20 | Fay | Pat | 6000 | 6000 | 20 | Hartstein | Michael | 13000 | 19000 | 30 | Baida | Shelli | 2900 | 2900 | 30 | Colmenares | Karen | 2500 | 5400 | 30 | Himuro | Guy | 2600 | 8000 | 30 | Khoo | Alexander | 3100 | 8200 | 30 | Raphaely | Den | 11000 | 16700 | 30 | Tobias | Sigal | 2800 | 16900 | 40 | Mavris | Susan | 6500 | 6500 | 50 | Atkinson | Mozhe | 2800 | 2800 | 50 | Bell | Sarah | 4000 | 6800 | 50 | Bissot | Laura | 3300 | 10100 | 50 | Bull | Alexis | 4100 | 11400 | 50 | Cabrio | Anthony | 3000 | 10400 | 50 | Chung | Kelly | 3800 | 10900 | 50 | Davies | Curtis | 3100 | 9900 | 50 | Dellinger | Julia | 3400 | 10300 | 50 | Dilly | Jennifer | 3600 | 10100 | 50 | Everett | Britney | 3900 | 10900 | 50 | Feeney | Kevin | 3000 | 10500 | 50 | Fleaur | Jean | 3100 | 10000 | 50 | Fripp | Adam | 8200 | 14300 | 50 | Gates | Timothy | 2900 | 14200 | 50 | Gee | Ki | 2400 | 13500 | 50 | Geoni | Girard | 2800 | 8100 | 50 | Grant | Douglas | 2600 | 7800 | 50 | Jones | Vance | 2800 | 8200 | 50 | Kaufling | Payam | 7900 | 13300 | 50 | Ladwig | Renske | 3600 | 14300 | 50 | Landry | James | 2400 | 13900 | 50 | Mallin | Jason | 3300 | 9300 | 50 | Markle | Steven | 2200 | 7900 | 50 | Marlow | James | 2500 | 8000 | 50 | Matos | Randall | 2600 | 7300 | 50 | McCain | Samuel | 3200 | 8300 | 50 | Mikkilineni | Irene | 2700 | 8500 | 50 | Mourgos | Kevin | 5800 | 11700 | 50 | Nayer | Julia | 3200 | 11700 | 50 | OConnell | Donald | 2600 | 11600 | 50 | Olson | TJ | 2100 | 7900 | 50 | Patel | Joshua | 2500 | 7200 | 50 | Perkins | Randall | 2500 | 7100 | 50 | Philtanker | Hazel | 2200 | 7200 | 50 | Rajs | Trenna | 3500 | 8200 | 50 | Rogers | Michael | 2900 | 8600 | 50 | Sarchand | Nandita | 4200 | 10600 | 50 | Seo | John | 2700 | 9800 | 50 | Stiles | Stephen | 3200 | 10100 | 50 | Sullivan | Martha | 2500 | 8400 | 50 | Taylor | Winston | 3200 | 8900 | 50 | Vargas | Peter | 2500 | 8200 | 50 | Vollman | Shanta | 6500 | 12200 | 50 | Walsh | Alana | 3100 | 12100 | 50 | Weiss | Matthew | 8000 | 17600 | 60 | Austin | David | 4800 | 4800 | 60 | Ernst | Bruce | 6000 | 10800 | 60 | Hunold | Alexander | 9000 | 19800 | 60 | Lorentz | Diana | 4200 | 19200 | 60 | Pataballa | Valli | 4800 | 18000 | 70 | Baer | Hermann | 10000 | 10000 | 80 | Abel | Ellen | 11000 | 11000 | 80 | Ande | Sundar | 6400 | 17400 | 80 | Banda | Amit | 6200 | 23600 | 80 | Bates | Elizabeth | 7300 | 19900 | 80 | Bernstein | David | 9500 | 23000 | 80 | Bloom | Harrison | 10000 | 26800 | 80 | Cambrault | Gerald | 11000 | 30500 | 80 | Cambrault | Nanette | 7500 | 28500 | 80 | Doran | Louise | 7500 | 26000 | 80 | Errazuriz | Alberto | 12000 | 27000 | 80 | Fox | Tayler | 9600 | 29100 | 80 | Greene | Danielle | 9500 | 31100 | 80 | Hall | Peter | 9000 | 28100 | 80 | Hutton | Alyssa | 8800 | 27300 | 80 | Johnson | Charles | 6200 | 24000 | 80 | King | Janette | 10000 | 25000 | 80 | Kumar | Sundita | 6100 | 22300 | 80 | Lee | David | 6800 | 22900 | 80 | Livingston | Jack | 8400 | 21300 | 80 | Marvins | Mattea | 7200 | 22400 | 80 | McEwen | Allan | 9000 | 24600 | 80 | Olsen | Christopher | 8000 | 24200 | 80 | Ozer | Lisa | 11500 | 28500 | 80 | Partners | Karen | 13500 | 33000 | 80 | Russell | John | 14000 | 39000 | 80 | Sewall | Sarath | 7000 | 34500 | 80 | Smith | Lindsey | 8000 | 29000 | 80 | Smith | William | 7400 | 22400 | 80 | Sully | Patrick | 9500 | 24900 | 80 | Taylor | Jonathon | 8600 | 25500 | 80 | Tucker | Peter | 10000 | 28100 | 80 | Tuvault | Oliver | 7000 | 25600 | 80 | Vishney | Clara | 10500 | 27500 | 80 | Zlotkey | Eleni | 10500 | 28000 | 90 | De Haan | Lex | 17000 | 17000 | 90 | King | Steven | 24000 | 41000 | 90 | Kochhar | Neena | 17000 | 58000 | 100 | Chen | John | 8200 | 8200 | 100 | Faviet | Daniel | 9000 | 17200 | 100 | Greenberg | Nancy | 12008 | 29208 | 100 | Popp | Luis | 6900 | 27908 | 100 | Sciarra | Ismael | 7700 | 26608 | 100 | Urman | Jose Manuel | 7800 | 22400 | 110 | Gietz | William | 8300 | 8300 | 110 | Higgins | Shelley | 12008 | 20308 | - | Grant | Kimberely | 7000 | 7000 |
---|