Reworked SQL