Transform workers_info Table to Exclude NULL Values
 

Given a table named playground.workers_info, write a SQL query to transform this table. The transformation should result in a table with three columns: id, column_name, and value, where column_name is the name of the original column containing a non-NULL value for each id, and value is the stringified non-NULL value from this column. Exclude rows where the original value is NULL. The result should be sorted by id in ascending order, and for rows with the same id, sorted by column_name in ascending order.

These are the tables to query for this question:
playground.workers_info
  • id int
  • name string
  • date_of_birth date
  • salary int
Your answer should include these columns:
  • id integer
  • column_name varchar
  • value varchar

Querying is only for logged in users!

Write Your Query Here (you can run selections by highlighting!)

Query Results

No queries have been run yet.