1
2
3
4
5
6
7
8
9
10
11
12
13
| select a.session_id,a.created_at,a.province,a.referer,a.uri,a.ipv4,
a.user_id,b.duration,b.num
from statistics as a
inner join (
select session_id,
max(created_at) as latest_time,
count(*) as num,sum(duration) as duration
from statistics
group by session_id
) as b
on a.session_id=b.session_id
and a.created_at=b.latest_time
ORDER BY a.created_at desc
|