[Solved] Can someone explain this SQL for me?


You have a table called reports and you are extracting a table that consists of the id, user, item_id, and created fields. This new table will only have rows that contain the max value of created for each distinct item_id.

This part extracts the fields you want:

select a.id,
       a.user,
       a.item_id,
       a.created

From a table called reports (a):

  from reports as a

Only extract the rows that satisfy the condition:

 where a.created = (select max(created) 
                      from reports as b
                     where a.item_id = b.item_id)

3

solved Can someone explain this SQL for me?