$ 0 0 Try using: select event, logonsource, username, max(logontime) from log_TABLE group by event, logonsource, username