Home > database >  SQL cumulative problem
SQL cumulative problem

Time:09-26

This topic to do then, with the sum not ah

CodePudding user response:

 USE tempdb for 
GO
IF OBJECT_ID (' t ') IS NOT NULL
DROP TABLE t
GO
CREATE TABLE (t
Player_id INT,
Device_id INT,
Event_date DATETIME,
Games_played INT
)
GO
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 2, '2016-03-01', 5)
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 2, '2016-05-02', 6)
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 3, '2017-06-25', 1)

SELECT *, SUM (games_played) OVER (ORDER BY t.e vent_date) AS the result FROM t


CodePudding user response:

I see, thank you

CodePudding user response:

reference 1/f, gypsy song response:
 USE tempdb for 
GO
IF OBJECT_ID (' t ') IS NOT NULL
DROP TABLE t
GO
CREATE TABLE (t
Player_id INT,
Device_id INT,
Event_date DATETIME,
Games_played INT
)
GO
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 2, '2016-03-01', 5)
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 2, '2016-05-02', 6)
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 3, '2017-06-25', 1)

SELECT *, SUM (games_played) OVER (ORDER BY t.e vent_date) AS the result FROM t



Digression, how do you send the figure of ah, why I can only type?

CodePudding user response:

reference persistencezyx reply: 3/f
Quote: refer to 1st floor gypsy song response:
 USE tempdb for 
GO
IF OBJECT_ID (' t ') IS NOT NULL
DROP TABLE t
GO
CREATE TABLE (t
Player_id INT,
Device_id INT,
Event_date DATETIME,
Games_played INT
)
GO
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 2, '2016-03-01', 5)
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 2, '2016-05-02', 6)
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 3, '2017-06-25', 1)

SELECT *, SUM (games_played) OVER (ORDER BY t.e vent_date) AS the result FROM t



Digression, how do you send the figure of ah, why I can only type?



Computer browser, Posting points icon,

If ok, will give points junction post bar,

CodePudding user response:

reference 4 floor gypsy song response:
Quote: refer to the third floor persistencezyx response:

Quote: refer to 1st floor gypsy song response:
 USE tempdb for 
GO
IF OBJECT_ID (' t ') IS NOT NULL
DROP TABLE t
GO
CREATE TABLE (t
Player_id INT,
Device_id INT,
Event_date DATETIME,
Games_played INT
)
GO
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 2, '2016-03-01', 5)
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 2, '2016-05-02', 6)
INSERT INTO t (player_id, device_id event_date, games_played) VALUES (1, 3, '2017-06-25', 1)

SELECT *, SUM (games_played) OVER (ORDER BY t.e vent_date) AS the result FROM t



Digression, how do you send the figure of ah, why I can only type?



Computer browser, Posting points icon,

If ok, will give points junction post bar,

Oh, oh, I see with my cell phone, so no
  • Related