Trying to list block_recip entries in order in which they were last used, including the number of times each one was used, omitting ones which were never used: select block_recip.email as email, from_unixtime(max(block_recip_hits.timestamp)) as last, count(*) from block_recip left join block_recip_hits on block_recip.email = block_recip_hits.email where block_recip.enabled = "1" and last is not null group by block_recip.email order by max(block_recip_hits.timestamp); I get: ERROR 1054 (42S22): Unknown column 'last' in 'WHERE' So the “last” column can’t be referenced in a “where”-clause because it doesnt’ actually exist until after the “group by” takes effect. But this works: select block_recip.email as email, from_unixtime(max(block_recip_hits.timestamp)) as last, count(*) from block_recip left join block_recip_hits on block_recip.email = block_recip_hits.email where block_recip.enabled = "1" group by block_recip.email having last is not null order by max(block_recip_hits.timestamp);