Select Earliest Date and Time from List of Distinct User Sessions

前端 未结 2 1156
伪装坚强ぢ
伪装坚强ぢ 2021-01-20 09:58

I have a table of user access sessions which records website visitor activity:

accessid, userid, date, time, url

I\'m trying to retrieve all dis

2条回答
  •  猫巷女王i
    2021-01-20 10:21

    Try this

    SELECT 
        accessid, 
        date, 
        time 
    FROM 
        accesslog 
    WHERE userid = '1234' 
    GROUP BY accessid
    HAVING MIN(date)
    

    It will return all unique accesses with minimum time for each for userid = '1234'.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题