runtime
75 / 139

task RANK / DENSE_RANK · medium

Predict: positions and shared ranks

Predict the three ranking columns for the sample of Seattle hitters.

what to return

Columns
player_idhome_runsrnkdenserow_num 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: RANK & DENSE_RANK →

data you can query

hitter_sample2 columns · 7 rows
player_idhome_runs
canzd00111
crawj00212
garvm0019
moord0029
naylj0019
suare00113
tellr00111
player_id
canzd001
home_runs
11
player_id
crawj002
home_runs
12
player_id
garvm001
home_runs
9
player_id
moord002
home_runs
9
player_id
naylj001
home_runs
9
player_id
suare001
home_runs
13
player_id
tellr001
home_runs
11

all 7 rows

predict.sql
SELECT
  player_id,
  home_runs,
  RANK() OVER (ORDER BY home_runs DESC) AS rnk,
  DENSE_RANK() OVER (ORDER BY home_runs DESC) AS dense,
  ROW_NUMBER() OVER (ORDER BY home_runs DESC, player_id) AS row_num
FROM hitter_sample
ORDER BY row_num
prediction.json

Enter the rows you think the query returns, column order player_id, home_runs, rnk, dense, row_num. JSON array of rows — numbers bare, text in quotes, null for NULL. Example: [ [ 1, null, null, null, null ] ]. Keep ORDER BY order.

 
Output

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

Predict: positions and shared ranks — SQL practice · Runtime