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.

more info can be found here

SQL
Fundamentals

Stats:

CreatedOct 27, 2016
PublishedOct 28, 2016
Warriors Trained8687
Total Skips2724
Total Code Submissions21893
Total Times Completed2864
SQL Completions2865
Total Stars180
% of votes with a positive feedback rating86% of 364
Total "Very Satisfied" Votes275
Total "Somewhat Satisfied" Votes73
Total "Not Satisfied" Votes16
Total Rank Assessments8
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • matt c Avatar
  • jhoffner Avatar
  • smile67 Avatar
  • ejini战神 Avatar
  • 4500zenja1 Avatar
Ad