SQL time difference within single table

前端 未结 1 884
盖世英雄少女心
盖世英雄少女心 2021-01-22 14:42


I have a single MySQL table with login data of users.

user |  date               | type
-----+---------------------+------
1    | 2011-01-05 08:00:00 | login         


        
1条回答
  •  醉梦人生
    2021-01-22 15:29

    SELECT x.*, TIMEDIFF(x.logout_date, x.login_date) as duration
    FROM
    (
    SELECT a.user_id, a.`date` as logout_date, 
    (SELECT MAX(b.`date`) FROM table1 b WHERE b.`date` 

    0 讨论(0)
提交回复
热议问题