CS 6515 EXAMINATION 3 VERSION C ACTUAL TEST PAPER QUESTIONS CORRECT ANSWERS
GRADED A PLUS
Question:
Look at figure on 9.5.2 What select statement gives the given result. 92300 a) SELECT SUM(price)
FROM auto; b) SELECT AVG(price) FROM auto; c) SELECT MAX(price) FROM auto;
Answer:
a (The sum of the price is selected)
Question:
Look at figure on 9.5.5 What select statement gives the result. Ford 1 Honda 2 Toyota 3
Volkswagen 1 a) SELECT make, COUNT(*) FROM auto; b) SELECT make, COUNT(*) FROM
auto GROUP BY make; c) SELECT COUNT(*) FROM auto GROUP BY make;
Answer:
b (The automobiles are listed by make and the number in each make group)
Question:
Look at figure on 9.5.5 What select statement gives the result. 2014 8800 2015 16400 2016 12675 a)
SELECT year, AVG(price) FROM auto GROUP BY year; b) SELECT year, AVG(year) FROM
auto GROUP BY year; c) SELECT price, AVG(price) FROM auto GROUP BY year;
Answer:
a (The average price is displayed for each year group)
Question:
Look at figure on 9.5.5 What select statement gives the result. 2015 16400 2016 12675 a) SELECT
year, AVG(price) FROM auto GROUP BY year; b) SELECT year, AVG(price) FROM auto
WHERE AVG(price) > 9000 GROUP BY year; c) SELECT year, AVG(price) FROM auto GROUP
BY year HAVING AVG(price) > 9000;
,Answer:
c (The aggregate function AVG() finds the average price for each year. The HAVING clause then
selects only groups with an average price above $9000, which excludes the 2014 row with an $8800
average price)
Question:
Look at figure on 9.5.5 What select statement gives the result. compact 8800 sedan 10200 suv 16900
crossover 17900 a) SELECT type, MAX(price) FROM auto GROUP BY type; b) SELECT type,
MAX(price) FROM auto GROUP BY type ORDER BY price; c) SELECT type, MAX(price)
FROM auto GROUP BY type ORDER BY MAX(price);
Answer:
c (The results are sorted by the largest price in each type group)
Question:
2014 compact 8800 2015 crossover 15900 2015 suv 16900 2016 sedan 10200 2016 crossover 17900
a) SELECT year, MAX(price) FROM auto GROUP BY year, type ORDER BY year, MAX(price);
b) SELECT year, type, MAX(price) FROM auto GROUP BY year ORDER BY year, MAX(price);
c) SELECT year, type, MAX(price) FROM auto GROUP BY year, type ORDER BY year,
MAX(price);
Answer:
c (The results show the largest price in each year and type)
Question:
Look at figure 9.5.6 What select statements return the given result. a) SELECT x + y FROM
problem; b) SELECT x - y FROM problem; c) SELECT x * y FROM problem;
Answer:
a (The numbers are the sum of the numbers in the x and y columns: 7 = 5 + 2, 10 = 9 + 1, 13 = 3 +
10)
Question:
,Look at figure 9.5.6 What select statements return the given result. a) SELECT x - y FROM
problem; b) SELECT ABS(x - y) FROM problem; c) SELECT -1 * (x - y) FROM problem;
Answer:
b (The numbers are the absolute values of the x column minus the y column)
Question:
Look at figure 9.5.6 What select statements return the given result. a) SELECT x / y FROM
problem; b) SELECT ROUND(x / y, 0) FROM problem; c) SELECT ROUND(x / y, 1) FROM
problem;
Answer:
b (After dividing the numbers in the x column by the numbers in the y column, the answer is
rounded to 0 decimal places: 3 = rounded, 9 = rounded, 0 = rounded)
Question:
Look at figure 9.5.6 What select statements return the given result. 2.2 3.0 1.7 a) SELECT
ROUND(x, 1) FROM problem; b) SELECT SQRT(x) FROM problem; c) SELECT
ROUND(SQRT(x), 1) FROM problem;
Answer:
c (The SQRT() function finds the square root of the x column, then ROUND() rounds the result to
one decimal place)
Question:
Look at figure 9.5.6 What select statements return the given result. 5 1 5 9 0 1 3 3 27 a) SELECT x,
POW(x, x % y) FROM problem; b) SELECT x, x % y, POW(x, y) FROM problem; c) SELECT x, x
% y, POW(x, x % y) FROM problem;
Answer:
c (The first column is x, the next column is the remainder of x divided by y, and the last column is x
to the power of the second column)
Question:
, Look at figure 9.5.7 What string will result from the select statement. SELECT CONCAT('Super ',
name) FROM avatar WHERE avatar_id = 1;
Answer:
Super Link (CONCAT() concatenates "Super " and "Link")
Question:
Look at figure 9.5.7 What string will result from the select statement. SELECT
LOWER(best_move) FROM avatar WHERE avatar_id = 3;
Answer:
psystrike (LOWER() lowercases Mewtwo's best_move)
Question:
Look at figure 9.5.7 What string will result from the select statement. SELECT
SUBSTRING(best_move, 7, 6) FROM avatar WHERE avatar_id = 4;
Answer:
Finale (SUBSTRING() returns the substring in "Mario Finale" that starts at position 7 and is 6
characters long. If the length argument is not given, SUBSTRING() returns all the characters to the
end of the string)
Question:
Look at figure 9.5.7 What string will result from the select statement. SELECT REPLACE(name,
"Kn", "Fr") FROM avatar WHERE avatar_id = 2;
Answer:
Meta Fright (REPLACE() replaces "Kn" in "Meta Knight" with "Fr")
Question:
Look at figure 9.5.9 What value does the select statement produce? SELECT TIME(due) FROM
assignment WHERE assign_id = 2;
Answer:
GRADED A PLUS
Question:
Look at figure on 9.5.2 What select statement gives the given result. 92300 a) SELECT SUM(price)
FROM auto; b) SELECT AVG(price) FROM auto; c) SELECT MAX(price) FROM auto;
Answer:
a (The sum of the price is selected)
Question:
Look at figure on 9.5.5 What select statement gives the result. Ford 1 Honda 2 Toyota 3
Volkswagen 1 a) SELECT make, COUNT(*) FROM auto; b) SELECT make, COUNT(*) FROM
auto GROUP BY make; c) SELECT COUNT(*) FROM auto GROUP BY make;
Answer:
b (The automobiles are listed by make and the number in each make group)
Question:
Look at figure on 9.5.5 What select statement gives the result. 2014 8800 2015 16400 2016 12675 a)
SELECT year, AVG(price) FROM auto GROUP BY year; b) SELECT year, AVG(year) FROM
auto GROUP BY year; c) SELECT price, AVG(price) FROM auto GROUP BY year;
Answer:
a (The average price is displayed for each year group)
Question:
Look at figure on 9.5.5 What select statement gives the result. 2015 16400 2016 12675 a) SELECT
year, AVG(price) FROM auto GROUP BY year; b) SELECT year, AVG(price) FROM auto
WHERE AVG(price) > 9000 GROUP BY year; c) SELECT year, AVG(price) FROM auto GROUP
BY year HAVING AVG(price) > 9000;
,Answer:
c (The aggregate function AVG() finds the average price for each year. The HAVING clause then
selects only groups with an average price above $9000, which excludes the 2014 row with an $8800
average price)
Question:
Look at figure on 9.5.5 What select statement gives the result. compact 8800 sedan 10200 suv 16900
crossover 17900 a) SELECT type, MAX(price) FROM auto GROUP BY type; b) SELECT type,
MAX(price) FROM auto GROUP BY type ORDER BY price; c) SELECT type, MAX(price)
FROM auto GROUP BY type ORDER BY MAX(price);
Answer:
c (The results are sorted by the largest price in each type group)
Question:
2014 compact 8800 2015 crossover 15900 2015 suv 16900 2016 sedan 10200 2016 crossover 17900
a) SELECT year, MAX(price) FROM auto GROUP BY year, type ORDER BY year, MAX(price);
b) SELECT year, type, MAX(price) FROM auto GROUP BY year ORDER BY year, MAX(price);
c) SELECT year, type, MAX(price) FROM auto GROUP BY year, type ORDER BY year,
MAX(price);
Answer:
c (The results show the largest price in each year and type)
Question:
Look at figure 9.5.6 What select statements return the given result. a) SELECT x + y FROM
problem; b) SELECT x - y FROM problem; c) SELECT x * y FROM problem;
Answer:
a (The numbers are the sum of the numbers in the x and y columns: 7 = 5 + 2, 10 = 9 + 1, 13 = 3 +
10)
Question:
,Look at figure 9.5.6 What select statements return the given result. a) SELECT x - y FROM
problem; b) SELECT ABS(x - y) FROM problem; c) SELECT -1 * (x - y) FROM problem;
Answer:
b (The numbers are the absolute values of the x column minus the y column)
Question:
Look at figure 9.5.6 What select statements return the given result. a) SELECT x / y FROM
problem; b) SELECT ROUND(x / y, 0) FROM problem; c) SELECT ROUND(x / y, 1) FROM
problem;
Answer:
b (After dividing the numbers in the x column by the numbers in the y column, the answer is
rounded to 0 decimal places: 3 = rounded, 9 = rounded, 0 = rounded)
Question:
Look at figure 9.5.6 What select statements return the given result. 2.2 3.0 1.7 a) SELECT
ROUND(x, 1) FROM problem; b) SELECT SQRT(x) FROM problem; c) SELECT
ROUND(SQRT(x), 1) FROM problem;
Answer:
c (The SQRT() function finds the square root of the x column, then ROUND() rounds the result to
one decimal place)
Question:
Look at figure 9.5.6 What select statements return the given result. 5 1 5 9 0 1 3 3 27 a) SELECT x,
POW(x, x % y) FROM problem; b) SELECT x, x % y, POW(x, y) FROM problem; c) SELECT x, x
% y, POW(x, x % y) FROM problem;
Answer:
c (The first column is x, the next column is the remainder of x divided by y, and the last column is x
to the power of the second column)
Question:
, Look at figure 9.5.7 What string will result from the select statement. SELECT CONCAT('Super ',
name) FROM avatar WHERE avatar_id = 1;
Answer:
Super Link (CONCAT() concatenates "Super " and "Link")
Question:
Look at figure 9.5.7 What string will result from the select statement. SELECT
LOWER(best_move) FROM avatar WHERE avatar_id = 3;
Answer:
psystrike (LOWER() lowercases Mewtwo's best_move)
Question:
Look at figure 9.5.7 What string will result from the select statement. SELECT
SUBSTRING(best_move, 7, 6) FROM avatar WHERE avatar_id = 4;
Answer:
Finale (SUBSTRING() returns the substring in "Mario Finale" that starts at position 7 and is 6
characters long. If the length argument is not given, SUBSTRING() returns all the characters to the
end of the string)
Question:
Look at figure 9.5.7 What string will result from the select statement. SELECT REPLACE(name,
"Kn", "Fr") FROM avatar WHERE avatar_id = 2;
Answer:
Meta Fright (REPLACE() replaces "Kn" in "Meta Knight" with "Fr")
Question:
Look at figure 9.5.9 What value does the select statement produce? SELECT TIME(due) FROM
assignment WHERE assign_id = 2;
Answer: