Construct a SQL statement that selects the name, ID, address, and phone number from a table called "people" where the age of the person is greater than 25 and their address is in a specific zip code range between 90001 and 90010. Additionally, the result should be sorted in descending order based on the person's ID number. Lastly, the query should be written using a subquery that joins the "people" table with a separate table called "phone_numbers" where the person's phone number is stored, and the subquery should only select phone numbers that are not null.
user
here's a possible sql statement that meets those requirements: select name, id, address, phone_number from people left join phone_numbers on people.id = phone_numbers.id where people.age > 25 and zip_code between 90001 and 90010 order by people.id desc;
assistant
Here's a possible SQL statement that meets those requirements: SELECT name, ID, address, phone_number FROM people LEFT JOIN phone_numbers ON people.ID = phone_numbers.ID WHERE people.age > 25 AND zip_code BETWEEN 90001 AND 90010 ORDER BY people.ID DESC;
assistant