Handy SOQL query snippets

To count how many people logged in for the last time each year, for only inactive users:

select calendar_year(lastlogindate) LoginYear,count(id) Total
from user
where isactive = false
and lastlogindate <> null
group by calendar_year(lastlogindate)
order by count(id) desc