Perhaps this code would do what you need:
SELECT event, logonsource, username, RANK() OVER (PARTITION BY username ORDER BY logontime DESC) AS RankedLogons FROM log_TABLE QUALIFY RankedLogons <=2;
↧