5 kyu
SQL Basics: Simple PIVOTING data
2,865 of 2,864matt c
Description:
For this challenge you need to PIVOT data. You have two tables, products and details. Your task is to pivot the rows in products to produce a table of products which have rows of their detail. Group and Order by the name of the Product.
Tables and relationship below:

products
table schema
- id - integer
- name - text
details
table schema
- id - integer
- product_id - integer
- detail - text
You must use the CROSSTAB statement to create a table that has the schema as below:
CROSSTAB table schema
- name - text
- bad - bigint
- good - bigint
- ok - bigint
If the values aren't assigned to the last three columns within the query directly, it's assumed they will be presented in the lexicographical order (i.e. if we have three values, a
, b
and c
, then bad
, good
and ok
will have these values respectively).
Compare your table to the expected table to view the expected results.
SQL
Fundamentals
Similar Kata:
Stats:
Created | Oct 27, 2016 |
Published | Oct 28, 2016 |
Warriors Trained | 8687 |
Total Skips | 2724 |
Total Code Submissions | 21893 |
Total Times Completed | 2864 |
SQL Completions | 2865 |
Total Stars | 180 |
% of votes with a positive feedback rating | 86% of 364 |
Total "Very Satisfied" Votes | 275 |
Total "Somewhat Satisfied" Votes | 73 |
Total "Not Satisfied" Votes | 16 |
Total Rank Assessments | 8 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |