SQL: Pivot Employee Data

Medium
SQL — Advanced SQL CASE WHEN Pivot
Transform rows to columns for attendance.

Constraints

Write standard SQL (MySQL 8.0 compatible).

Examples

Example 1:
Input: name day status Ahmed Mon Present Ahmed Tue Absent
Output:
Example 2:
Input: name day status Ahmed Mon Present Ahmed Tue Absent
Output:

Hints

CASE WHEN or PIVOT.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.