runtime
74 / 139

task GROUP BY · medium

Predict: count rows or known values?

Predict the single row of counts over the sample products.

what to return

Columns
productspricedcategories in this order
Rows
in the order asked
Watch for
Use only the sample rows shown. NULL is not zero or empty text. Keep duplicate rows.
Skill
Reason about the exact result of a fixed SQL query. Refresher: COUNT, SUM & AVG →

data you can query

Retail dataset: the first 6 rows of each table. Under each column name: the kind of value it holds, and which table it links to. Your queries run on all rows.

product_sample4 columns · 10 rows
stock_codedescriptioncategory_idlist_price
21017RED BIRD HOUSE TREE DECORATION110.85
21018BIRD BOX CHRISTMAS TREE DECORATION10.85
21019NULLNULLNULL
21020NULLNULLNULL
21021NULLNULLNULL
21022NULLNULLNULL
stock_code
21017
description
RED BIRD HOUSE TREE DECORATION
category_id
11
list_price
0.85
stock_code
21018
description
BIRD BOX CHRISTMAS TREE DECORATION
category_id
1
list_price
0.85
stock_code
21019
description
NULL
category_id
NULL
list_price
NULL
stock_code
21020
description
NULL
category_id
NULL
list_price
NULL
stock_code
21021
description
NULL
category_id
NULL
list_price
NULL
stock_code
21022
description
NULL
category_id
NULL
list_price
NULL

first 6 of 10 rows · your queries use all of them

predict.sql
SELECT
  COUNT(*) AS products,
  COUNT(list_price) AS priced,
  COUNT(DISTINCT category_id) AS categories
FROM product_sample
Read the query · predict its result
SELECT COUNT(*) AS products, COUNT(list_price) AS priced, COUNT(DISTINCT category_id) AS categories FROM product_sample

Look at the sample tables and SQL. Enter the rows you think the query returns, in this column order: products, priced, categories. Put each row in square brackets, then wrap all rows in another pair of brackets (JSON format). For example, [[1,null,null]] is one row with 3 values. Replace these with your predicted values. Use numbers without quotes, text in double quotes, and null for SQL NULL. Keep repeated rows. Use [] for no rows. Keep rows in the order specified by ORDER BY.

Hints and the answer are always available. Using them counts the question as solved with help.

Predict: count rows or known values? — SQL practice · Runtime