SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE UserAction ([UserID] int, [StageID] int, [BattleID] int,[ActionTime] datetime, [Duration] int); INSERT INTO UserAction ([UserID], [StageID], [BattleID], [ActionTime], [Duration]) VALUES (3502,1,35021,'2020-04-25 10:12:00', 13), (3502,2,35022,'2020-04-25 02:32:00', 25), (3502,3,35023,'2020-04-25 13:42:08', 50), (3502,4,35024,'2020-04-25 16:10:05', 72), (3502,1,35025,'2020-04-25 08:11:40', 12), (2109,1,21091,'2020-04-25 12:10:02', 10), (2109,2,21092,'2020-04-25 18:17:40', 20), (6593,1,65931,'2020-04-25 20:42:30', 17), (6593,2,65932,'2020-04-25 11:18:45', 30), (6593,3,65933,'2020-04-25 03:08:35', 47), (6593,3,65933,'2020-04-25 03:08:35', 47), (1500,1,15001,'2020-04-25 16:38:15', 10), (1500,2,15002,'2020-04-25 11:13:22', 28), (1500,3,15003,'2020-04-25 13:18:15', 49), (1500,4,15004,'2020-04-25 19:32:43', 63), (1500,5,15005,'2020-04-25 23:11:43', 45); SELECT UserID, StageID, COUNT(DISTINCT BattleID) BattlesCount, SUM(Duration) BattlesDuration FROM UserAction GROUP BY UserID, StageID

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear