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

تم الإنشاء في: ٧ نوفمبر ٢٠٢٦

تمت الإجابة باستخدام 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.

مشاركة هذا السؤال والجواب