Github Copilot · Free Practice Question Medium
Question 22
You are working on a project that requires frequent SQL queries to retrieve specific information. GitHub Copilot helps generate queries, but they can sometimes be inefficient or lack critical filtering conditions. Which prompt revision would improve the efficiency and accuracy of SQL query generation using GitHub Copilot?
-
A
"Generate an SQL query to retrieve data from a database."
-
B
"Write an SQL query to retrieve all user data from the 'users' table."
-
C
"Write an SQL query to retrieve user data (user_id, first_name, last_name) from the 'users' table, but only where the user’s status is active and the user was created after 2021-01-01."
-
D
"Create an SQL query that pulls data from a table using user data."
Reveal correct answer
Correct answer: C
A.
This prompt is far too general and does not specify the table or columns, nor does it include any filtering conditions. GitHub Copilot would likely generate a simple SELECT * query without any optimization or relevant conditions.
B.
Although this prompt specifies the table, it lacks any filtering conditions or details about which columns are needed. A SELECT * query might be generated, which is not efficient if only specific fields or filtered results are needed.
C.
This is a highly effective prompt because it specifies the table (users), the fields to retrieve (user_id, first_name, last_name), and adds filtering conditions for the user’s status (active) and creation date (after 2021-01-01). GitHub Copilot is more likely to generate a query that meets your needs and avoids inefficiency.
D.
This prompt is too ambiguous. It does not specify the table, the columns, or the filtering conditions. Copilot might generate a query but with a lot of guesswork, leading to inefficient or incorrect results.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
