Introduction to SQL
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    Introduction to SQL

    Here you can access the books table used in the course.


    Note: When using sample integrations such as those that contain course data, you have read-only access. You can run queries, but cannot make any changes such as adding, deleting, or modifying the data (e.g., creating tables, views, etc.).

    Take Notes

    Add notes about the concepts you've learned and SQL cells with queries you want to keep.

    Add your notes here

    Unknown integration
    DataFrameavailable as
    books
    variable
    -- Add your own queries here
    SELECT * 
    FROM books
    
    SELECT DISTINCT author AS unique_author
    FROM books;
    
    CREATE VIEW library_authors AS
    SELECT DISTINCT author AS unique_author
    FROM books;
    
    -- Select all columns from library_authors
    SELECT *
    FROM library_authors;
    
    postgresql limit
    SELECT genre
    FROM books
    LIMIT 10;
    
    SELECT COUNT(film_id) AS count_film_id
    FROM reviews;
    
    SELECT COUNT(language) AS count_languages, COUNT(country) AS count_countries
    FROM films;
    
    SELECT COUNT(DISTINCT country) AS count_distinct_countries
    FROM films;
    
    SELECT COUNT(language) AS count_spanish
    FROM films
    WHERE language = 'Spanish'
    
    
    SELECT title, release_year
    FROM films
    WHERE (release_year = 1990 OR release_year = 1999)
    	AND (language = 'English' OR language = 'Spanish')
    -- Filter films with more than $2,000,000 gross
    	AND gross > 2000000;
    	
    SELECT title, release_year
    FROM films
    WHERE release_year BETWEEN 1990 AND 2000
    	AND budget > 100000000
    -- Amend the query to include Spanish or French-language films
    	AND (language = 'Spanish' OR language = 'French');
    
    
    SELECT COUNT (DISTINCT title) AS nineties_english_films_for_teens
    FROM films
    -- Filter to release_years to between 1990 and 1999
    WHERE release_year BETWEEN 1990 AND 1999
    -- Filter to English-language films
    AND language = ('English')
    -- Narrow it down to G, PG, and PG-13 certifications
    AND certification IN ('G', 'PG', 'PG-13');
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.

    Explore Datasets

    Use the books table to explore the data and practice your skills!

    • Select only the title column.
    • Alias the title column as book_title.
    • Select the distinct author names from the author column.
    • Select all records from the table and limit your results to 10.