is there a better way of writing this SQL

Printable View