clear markdown compare help donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 497325 fiddles created (9553 in the last week).

create table logs ( m_idPlayer varchar(20), Start_Time datetime, End_Time datetime, TotalPlayTime int, account varchar(20), SEQ int); insert into logs values ('0000001','2017/02/02 13:17.59','2017/02/02 13:23:11', 312,'developer',1), ('0000001','2017/02/02 13:23:51','2017/02/02 13:26:15', 144,'developer',2), ('0000001','2017/02/02 13:58:34','2017/02/02 14:13:42', 908,'developer',3), ('0000002','2017/02/02 14:16:45','2017/02/02 14:18:14', 89,'runewars21',4), ('0000003','2017/02/02 14:23:41','2017/02/02 14:25:59', 138,'speedyturtle',5), ('0000004','2017/02/02 14:27:00','2017/02/02 14:27:56', 56,'kevlaire05',6), ('0000005','2017/02/02 14:29:15','2017/02/02 14:32:25', 190,'infinity13',8), ('0000003','2017/02/02 14:26:09','2017/02/02 14:32:25', 376,'speedyturtle',9), ('0000002','2017/02/02 14:18:20','2017/02/02 14:37:21', 1141,'runewars21',10), ('0000001','2017/02/02 14:28:21','2017/02/02 14:37:42', 561,'developer',11);
10 rows affected
 hidden batch(es)


WITH grp AS ( SELECT account, m_idPlayer AS player, SUM(DATEDIFF(SECOND, Start_Time, End_Time)) Sec, DATEPART(DAY, Start_Time) as Dy from logs GROUP BY account, m_idPlayer, DATEPART(DAY, Start_Time) ) SELECT account, player, [1], [2], [3], [4] FROM (SELECT account, player, Sec, Dy FROM grp ) src PIVOT (SUM(Sec) FOR Dy IN ([1], [2], [3], [4])) as Pvt ;
account player 1 2 3 4
developer 0000001 1984
runewars21 0000002 1230
speedyturtle 0000003 514
kevlaire05 0000004 56
infinity13 0000005 190
 hidden batch(es)