This is the email based question get the answer co...

创建于:2026年11月7日

使用 GPT-6 Thinking 回答 Chat01

问题

IMG-20261107-WA0067.jpg
IMG-20261107-WA0068.jpg
IMG-20261107-WA0069.jpg
IMG-20261107-WA0070.jpg

This is the email based question get the answer correct without any error

思考

Worked for 5s

回答

Text version

Here is the correct MySQL solution for your CodeSignal database question.

Copy and paste this code into your editor:

sql
CREATE PROCEDURE solution() BEGIN SELECT c.candidate_id AS student_id FROM candidates c WHERE NOT EXISTS ( SELECT 1 FROM detentions d WHERE d.student_id = c.candidate_id ) ORDER BY c.candidate_id ASC; END

Expected Output

student_id
35
103

Why this works

  • SELECT gets student IDs from the candidates table.
  • NOT EXISTS excludes students who have received any detention.
  • AS student_id gives the output column the required name.
  • ORDER BY sorts IDs in ascending order.

Important: Your editor already contains CREATE PROCEDURE solution(), BEGIN, and END. If you keep that template, paste only the SELECT statement inside BEGIN and END to avoid duplicate procedure definitions.

This solution is valid for MySQL and handles students with multiple detentions correctly.

分享这个问答