Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Student-Class Report with Defaults | Handling NULLs, Performance, and Real-World Join Scenarios
SQL Joins in Depth

bookChallenge: Student-Class Report with Defaults

Task

Swipe to start coding

Write a query to generate a report listing each student's name and their class name. If a student does not have a class assigned, display 'Unassigned' instead of a NULL class name.

  • Use a LEFT JOIN to combine the students and classes tables based on the class_id.
  • Select the student's name from the students table.
  • Select the class name from the classes table, replacing any NULL values with 'Unassigned' using the COALESCE function.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 2
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: Student-Class Report with Defaults

Swipe to show menu

Task

Swipe to start coding

Write a query to generate a report listing each student's name and their class name. If a student does not have a class assigned, display 'Unassigned' instead of a NULL class name.

  • Use a LEFT JOIN to combine the students and classes tables based on the class_id.
  • Select the student's name from the students table.
  • Select the class name from the classes table, replacing any NULL values with 'Unassigned' using the COALESCE function.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 2
single

single

some-alt