Need help to simplify/optimize sql query

Printable View