Ga naar inhoud

Header

Retrieving data with SELECT - Assignments

1. Retrieving all data of all actors

Complete the following query to obtain all data from the actors table.

Header

  • Use the SELECT and FROM statements.
SELECT
  *
FROM
  actors;
id first_name last_name gender film_count
933 Lewis Abernathy M 1
2547 Andrew Adamson M 1
2700 William Addy M 1
... ... ... ... ...
Columns: 5
Rows: 1,907




2. Retrieving the number of actors

Complete the following query to calculate the number of rows (number of actors) in the actors table.

You should see a number as a result.

  • Use the SELECT and FROM statements.
  • Use the COUNT() function.
SELECT
  COUNT(*)
FROM
  actors
count
1907




3. Retrieving first and last names of actors

Complete the following query to obtain data from the first_name and last_name columns from the actors table.

  • Use the SELECT and FROM statements.
SELECT
  first_name,
  last_name
FROM
  actors;
first_name last_name
Lewis Abernathy
Andrew Adamson
William Addy
... ...
Columns: 2
Rows: 1,907




4. Retrieving unique first names

Complete the following query to obtain unique values from the first_name column from the actors table.

  • Use the SELECT and FROM statements.
  • Use the DISTINCT statement.
SELECT
  DISTINCT first_name
FROM
  actors;
first_name
Giovanni
Carly
Ewan (I)
...
Columns: 1
Rows: 1,198




5. (Extra) Retrieving the number of unique first names

Create a query to calculate the number of unique first names in the actors table.

SELECT
  COUNT(DISTINCT first_name)
FROM
  actors;
count
1198