How to write sql statement for this kind of condition?

Printable View