A hospital has a patients table. The administrator wants to…

A hospital has a patients table. The administrator wants to view patients sorted by last name alphabetically. Which SQL statement works best? SELECT * FROM patients ORDER BY last_name SELECT * FROM patients GROUP BY last_name SELECT * FROM patients WHERE last_name ASC SELECT * FROM patients ORDER BY last_name DESC Answer: SELECT * FROM patients ORDER BY last_name Explanation: By default, ORDER BY sorts text in ascending order (A to Z). GROUP BY would group records, not sort them. Adding WHERE last_name ASC is invalid syntax. Using DESC would sort in reverse order (Z to A).

A hospital has a patients table with columns city and patien…

A hospital has a patients table with columns city and patient_id. Administrators want to see how many patients are in each city. Which query is correct? SELECT city, COUNT(patient_id) FROM patients GROUP BY city SELECT COUNT(patient_id) FROM patients SELECT city, patient_id FROM patients GROUP BY city SELECT * FROM patients ORDER BY city Answer: SELECT city, COUNT(patient_id) FROM patients GROUP BY city Explanation: COUNT(patient_id) counts patients per city when grouped by city. Without grouping, COUNT only gives the overall total. Grouping with non-aggregated fields like patient_id is invalid, and ORDER BY city just sorts rows without summarizing.

A retail chain wants to target customers from specific state…

A retail chain wants to target customers from specific states. Their customers table includes a state column. If they only want records where the state is either ‘WI’, ‘IL’, or ‘MN’, which SQL should they use? SELECT * FROM customers WHERE state = ‘WI’ AND ‘IL’ AND ‘MN’ SELECT * FROM customers WHERE state IN (‘WI’, ‘IL’, ‘MN’) SELECT * FROM customers WHERE state BETWEEN ‘WI’ AND ‘MN’ SELECT * FROM customers WHERE state LIKE ‘WIMNIL’ Answer: SELECT * FROM customers WHERE state IN (‘WI’, ‘IL’, ‘MN’) Explanation: The IN clause allows filtering by a specific set of values. Using AND would fail because a single record cannot equal multiple states at once. BETWEEN and LIKE are not appropriate for discrete, exact values.