私が持っている二つのテーブルMySQLのログインインスタンスによる平均セッション時間を計算する方法は?
ユーザー
id email
-------------------------------------------------------------
1 [email protected]
2 [email protected]
user_session_logs私は、ログインインスタンスによって層別セッション継続時間の分布を計算したい
id user_id start_timestamp end_timestamp
-------------------------------------------------------------
1 1 2016-01-01 12:00:00 2016-01-01 13:00:00
2 2 2016-01-01 14:00:00 2016-01-01 15:00:00
3 2 2016-02-03 06:00:00 2016-02-03 06:30:00
4 1 2016-03-03 05:00:00 2016-03-03 06:00:00
5 1 2016-04-03 07:00:00 2016-04-03 08:30:00
(最初のログイン、2番目のログイン、など) 。 は、したがって、上記のデータを考えると、私は
結果
login_instance average_session_duration_minutes
-------------------------------------------------------------
1 60 (this is the average of all user's 1st session duration)
2 45 (this is the average of all user's 2nd session duration)
3 90 (this is the average of all user's 3rd session duration)
これはmysqlのクエリで行うことができますどのように任意のアイデアを取得したいですか?
このawesomenessのおかげで! –