Quiz: SQL Grouping

  • Due Nov 22, 2013 at 11:59pm
  • Points 10
  • Questions 6
  • Available until Nov 23, 2013 at 12:05am
  • Time Limit None
  • Allowed Attempts 2

Instructions

For all of the questions in this quiz, you will use the following table:

mysql> SELECT * FROM web_users;
+--------+----------+-----------+----------+------+--------+
| userid | username | firstname | lastname | age  | gender |
+--------+----------+-----------+----------+------+--------+
|      1 | cworth   | Cathy     | Worth    |   58 | female |
|      2 | azayne   | Alice     | Zayne    |   14 | female |
|      3 | dverne   | David     | Verne    |   27 | male   |
|      4 | byoung   | Billy     | Young    |   42 | male   |
|      5 | euriel   | Emily     | Uriel    |   39 | female |
+--------+----------+-----------+----------+------+--------+

Use the following command to load the above tables from the mysql> prompt:

source /home/public/cs212/sql/web.sql

Use may also copy/paste the following SQL to create the tables:

CREATE TABLE web_users (
userid    INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
username  VARCHAR(15) NOT NULL UNIQUE,
firstname VARCHAR(15) NOT NULL,
lastname  VARCHAR(15) NOT NULL,
age       INTEGER NOT NULL,
gender    ENUM('female', 'male') NOT NULL);
INSERT INTO web_users VALUES
(1, 'cworth', 'Cathy', 'Worth', 58, 'female'),
(2, 'azayne', 'Alice', 'Zayne', 14, 'female'),
(3, 'dverne', 'David', 'Verne', 27, 'male'),
(4, 'byoung', 'Billy', 'Young', 42, 'male'),
(5, 'euriel', 'Emily', 'Uriel', 39, 'female');

Make sure you have this table setup before taking this quiz!

Only registered, enrolled users can take graded quizzes