0
0
MySQLquery~10 mins

GREATEST and LEAST in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select the greatest value between two columns 'score1' and 'score2'.

MySQL
SELECT GREATEST(score1, [1]) AS max_score FROM results;
Drag options to blanks, or click blank then click option'
Ascore2
Bscore1
Cscore3
Dscore4
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same column twice.
Using a column that does not exist.
2fill in blank
medium

Complete the code to select the least value between three columns 'price1', 'price2', and 'price3'.

MySQL
SELECT LEAST(price1, price2, [1]) AS min_price FROM products;
Drag options to blanks, or click blank then click option'
Aprice4
Bprice3
Cprice5
Dprice6
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column not in the table.
Forgetting to include all columns to compare.
3fill in blank
hard

Fix the error in the code to correctly find the greatest value between 'value1' and 'value2'.

MySQL
SELECT GREATEST([1], value2) AS highest FROM data;
Drag options to blanks, or click blank then click option'
A'value1'
Bvalue_1
CVALUE1
Dvalue1
Attempts:
3 left
💡 Hint
Common Mistakes
Putting column names in quotes.
Using incorrect column names.
4fill in blank
hard

Fill both blanks to select the least value between 'temp1' and 'temp2' and alias it as 'lowest_temp'.

MySQL
SELECT LEAST([1], [2]) AS lowest_temp FROM weather;
Drag options to blanks, or click blank then click option'
Atemp1
Btemp2
Ctemperature
Dtemp3
Attempts:
3 left
💡 Hint
Common Mistakes
Using columns not in the table.
Swapping the order does not affect the result but use the correct columns.
5fill in blank
hard

Fill all three blanks to select the greatest value among 'scoreA', 'scoreB', and 'scoreC' and alias it as 'top_score'.

MySQL
SELECT GREATEST([1], [2], [3]) AS top_score FROM exams;
Drag options to blanks, or click blank then click option'
AscoreA
BscoreB
CscoreC
DscoreD
Attempts:
3 left
💡 Hint
Common Mistakes
Including columns not in the table.
Missing one of the score columns.