write a report qurey in sql