SELECT *
FROM UserLoginHistory
WHERE loginDate BETWEEN '2022-10-03' AND '2022-10-09'
GROUP BY userId,loginDate
ORDER BY loginDate
How we can use LIMIT 0,5 Here so that we can LIMIT the records Date wise i.e 5 records per date
SELECT *
FROM UserLoginHistory
WHERE loginDate BETWEEN '2022-10-03' AND '2022-10-09'
GROUP BY userId,loginDate
ORDER BY loginDate
How we can use LIMIT 0,5 Here so that we can LIMIT the records Date wise i.e 5 records per date
I don't know if this is the right answer but I suggest you the following :
SELECT * FROM
(SELECT *, RANK() OVER(PARTITION BY userId ORDER BY loginDate DESC) rang
FROM UserLoginHistory
WHERE loginDate BETWEEN '2022-10-03' AND '2022-10-09'
GROUP BY userId,loginDate
ORDER BY loginDate) t
WHERE rang <= 5