Intermediate SQL - Selecting Data Flashcards
In this first chapter, you’ll learn how to query a films database and select the data needed to answer questions about the movies and actors. You'll also understand how SQL code is executed and formatted.
What is a query?
a request for data from a database
What keyword/function would we use to count the number of records with a value in a field?
COUNT()
True/False - If we want to count more than one field, we do not need to use COUNT() multiple times.
False - need to use the COUNT() function on each field you want to count
What does this query do? COUNT(field_name)
counts values in a field
What query do we use to count the number of records in a table?
COUNT(*)
What operator will remove duplicates to return only unique values?
DISTINCT
What two keywords can be combined to count the unique values in a field
COUNT() with DISTINCT - in this example, DISTINCT is excluding duplicates of people with the same birthday before COUNT()
True/False - COUNT() does not include duplicates
False - COUNT() includes duplicates
True/False - DISTINCT excludes duplicates
True
Unlike many programming languages, SQL is not what?
not processed in its written order
What is the first keyword that gets executed in SQL?
FROM - if we want to grab a coat/field from a closet/table, we need to know which closet/table to get it from
What keyword will limit how many results we return?
LIMIT
Its good to know processing order for what two reasons?
1) debugging
2) aliasing
Aliases are declared in which statement?
SELECT statement
What are the 3 common errors found when debugging SQL?
1) misspelling
2) incorrect capitalization
3) incorrect or missing punctuation, especially commas