Which SQL statement retrieves customer_id and name from customers where status='active'?

Enhance your skills with the CompTIA Data+ Certification Test. Engage with flashcards, tackle challenging multiple choice questions, complete with hints and explanations. Get yourself exam-ready now!

Multiple Choice

Which SQL statement retrieves customer_id and name from customers where status='active'?

Explanation:
The essential idea is to fetch specific columns from a table and apply a filter to return only the rows that meet a condition. The statement that selects customer_id and name from the customers table and restricts rows to those where status equals the string 'active' does exactly that: it targets the right columns, uses the correct table, and uses a string literal in the WHERE clause to compare the status value. The other statements go wrong in common ways: using a non-existent column name (id instead of customer_id), omitting the necessary quotes around a string (status = active), or using an invalid keyword (GET instead of SELECT).

The essential idea is to fetch specific columns from a table and apply a filter to return only the rows that meet a condition. The statement that selects customer_id and name from the customers table and restricts rows to those where status equals the string 'active' does exactly that: it targets the right columns, uses the correct table, and uses a string literal in the WHERE clause to compare the status value. The other statements go wrong in common ways: using a non-existent column name (id instead of customer_id), omitting the necessary quotes around a string (status = active), or using an invalid keyword (GET instead of SELECT).

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy