Intermediate Flashcards
(44 cards)
How can I return the number of RECORDS with a value in a FEILD
COUNT()
Table: people
Field: birthdate
write code that can count the number of birthdates in the birthdate field and return it with an alias; count_birthdates
SELECT COUNT(birthdate) AS count_birthdates
FROM people;
Table: people
Field: birthdate
write code that can count the number of birthdates in the birthdate field and return it with an alias; count_birthdates
SELECT COUNT(birthdate) AS count_birthdates
FROM people;
count the number of names (FIELD name) and the number of birthdates (FIELD birthdate) from the table; people
use; count_names and count_birthdates as aliases
SELECT COUNT(birthdate) AS count_birthdates, COUNT(name) AS count)names
FROM people;
How can you count the number of RECORDS (rows) in a table
(all records from people table, use alias total_records)
SELECT COUNT(*) AS total_records
FROM people;
How can I select the unique values from a FIELD
DISTINCT
remove all duplicates in the FIELD; languages from the TABLE; films
SELECT DISTINCT language
FROM films;
how can you count the unique number of items in a field
combine; COUNT(DISTINCT____)
count the unique birthdays from the FIELD; birthday and use the alias; unique_birthdays
Table; people
SELECT COUNT(DISTINCT birthdays) AS unique_birthdays
FROM people;
Here is a query counting film_id. Select the answer below that correctly describes what the query will return.
SELECT COUNT(film_id) AS count_film_id
FROM reviews;
The number of unique films in the reviews table.
The number of records containing a film_id.
The total number of records in the reviews table.
The sum of the film_id field.
The number of records containing a film_id.
In what order does the code run in SQL
SELECT
FROM
LIMIT
FROM
SELECT
LIMIT
What is the KEYWORD to filter text and numbers and where does it go?
what are the comparison opperators for
equal
not equal
less than
greater than
less than or equal to
greater than or equal to
keyword; WHERE
WHERE always comes after FROM statment.
= equal
<> not equal
< less than
> greater than
<= less than or equal to
>= greater than or equal to
Get all details for all films released in 2016.
TABLE; films
FIELD; release year
Get the number of films released before 2000.
TABLE; films
FIELD; release year
Get the title and release year of films released after 2000.
Get all details for all French language films.
TABLE: films
FIELD: language
Get the name and birth date of the person born on November 11th, 1974. Remember to use ISO date format (‘1974-11-11’)!
TABLE: people
FIELD: birthdate
Get the number of Hindi language films.
TABLE: films
FIELD; language
Get all details for all films with an R certification
TABLE; films
FIELD; certification