Forum Stats

  • 3,840,392 Users
  • 2,262,599 Discussions
  • 7,901,260 Comments

Discussions

Running Total

2908625
2908625 Member Posts: 12
edited Oct 7, 2015 1:19AM in SQLとPL/SQL

DROP TABLE cars;

CREATE TABLE cars

(MAKER VARCHAR2(33), "MODEL" VARCHAR2(33),

TOTAL NUMBER(6));

INSERT INTO cars

VALUES ('FORD', 'EDGE', 111);

INSERT INTO cars

VALUES ('TOYOTA', 'TUNDRA', 20);

INSERT INTO cars

VALUES ('KIA', 'SORRENTO', 14);

INSERT INTO cars

VALUES ('DODGE', 'RAM', 4);

select * from cars;


   


MAKERMODELTOTAL
FORDEDGE111
TOYOTATUNDRA20
KIASORRENTO14
DODGERAM3


I would like to use update this table to get a daily running total like:


 

MAKERMODEL2015100620151007
FORDEDGE111108
TOYOTATUNDRA2015
KIASORRENTO1413
DODGERAM33

ad infinitum so I can get diffs, trends etc.

Any help would be greatly appreciated.

Thanks,

Dane

Answers

  • Jagadekara
    Jagadekara Member Posts: 1,860 Gold Trophy
    edited Oct 7, 2015 1:19AM

    Hi,

    we don't understand your requirement.

    Explain clearly, provide required data.

    For running total check below example.

    SELECT EMPNO,SAL,SUM(SAL)

    OVER(ORDER BY EMPNO ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) RUNNING_TOTAL

    from emp

This discussion has been closed.