sql query to mimic 2
mimic 2 sql query