| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

DB2 累積計を作成する

提供: MyMemoWiki
ナビゲーションに移動 検索に移動

DB2 累積計を作成する

DB2 | Database |

select empno,firstnme,lastname, salary, sum(salary) over (order by salary, empno) as running_total
from employee
order by salary,empno
結果
EMPNO    FIRSTNME    LASTNAME     SALARY      RUNNING_TOTAL
------   ---------   ----------   ---------   -------------
200340  ROY        ALONZO       31840.00       31840.00
000290  JOHN       PARKER       35340.00       67180.00
200330  HELENA     WONG         35370.00      102550.00
000310  MAUDE      SETRIGHT     35900.00      138450.00
200310  MICHELLE   SPRINGER     35900.00      174350.00
000280  ETHEL      SCHNEIDER    36250.00      210600.00
000270  MARIA      PEREZ        37380.00      247980.00
000300  PHILIP     SMITH        37750.00      285730.00
200240  ROBERT     MONTEVERDE   37760.00      323490.00
200120  GREG       ORLANDO      39250.00      362740.00
000320  RAMLAL     MEHTA        39950.00      402690.00
000230  JAMES      JEFFERSON    42180.00      444870.00
000340  JASON      GOUNOT       43840.00      488710.00
000170  MASATOSHI  YOSHIMURA    44680.00      533390.00
000330  WING       LEE          45370.00      578760.00
200280  EILEEN     SCHWARTZ     46250.00      625010.00
200010  DIAN       HEMMINGER    46500.00      671510.00
000260  SYBIL      JOHNSON      47250.00      718760.00
000240  SALVATORE  MARINO       48760.00      767520.00
000250  DANIEL     SMITH        49180.00      816700.00
000120  SEAN       O'CONNELL    49250.00      865950.00
000220  JENNIFER   LUTZ         49840.00      915790.00
000190  JAMES      WALKER       50450.00      966240.00
000180  MARILYN    SCOUTTEN     51340.00     1017580.00
000150  BRUCE      ADAMSON      55280.00     1072860.00
000200  DAVID      BROWN        57740.00     1130600.00
000160  ELIZABETH  PIANKA       62250.00     1192850.00
200170  KIYOSHI    YAMAMOTO     64680.00     1257530.00
000110  VINCENZO   LUCCHESSI    66500.00     1324030.00
000210  WILLIAM    JONES        68270.00     1392300.00
000140  HEATHER    NICHOLLS     68420.00     1460720.00
200140  KIM        NATZ         68420.00     1529140.00
200220  REBA       JOHN         69840.00     1598980.00
000060  IRVING     STERN        72250.00     1671230.00
000130  DELORES    QUINTANA     73800.00     1745030.00
000050  JOHN       GEYER        80175.00     1825205.00
000100  THEODORE   SPENSER      86150.00     1911355.00
000090  EILEEN     HENDERSON    89750.00     2001105.00
000020  MICHAEL    THOMPSON     94250.00     2095355.00
000070  EVA        PULASKI      96170.00     2191525.00
000030  SALLY      KWAN         98250.00     2289775.00
000010  CHRISTINE  HAAS        152750.00     2442525.00