Skip to content
Introduction to SQL
Introduction to SQL
Here you can access the books table used in the course.
Take Notes
Add notes about the concepts you've learned and SQL cells with queries you want to keep.
Add your notes here
DataFrameas
df
variable
-- Return all titles from the books table
SELECT title
FROM books;DataFrameas
df
variable
-- Select title and author from the books table
SELECT title, author
FROM books;DataFrameas
books
variable
-- Select all fields from the books table
SELECT *
FROM books;
DataFrameas
df
variable
-- Select unique authors from the books table
SELECT DISTINCT author
FROM books;DataFrameas
df
variable
-- Select unique authors and genre combinations from the books table
SELECT DISTINCT author, genre
FROM books;DataFrameas
df
variable
-- Alias author so that it becomes unique_author
SELECT DISTINCT author AS unique_author
FROM books;DataFrameas
df
variable
-- Your code to create the view:
CREATE VIEW library_authors AS
SELECT DISTINCT author AS unique_author
FROM books;
-- Select all columns from library_authors
SELECT *
FROM library_authors;DataFrameas
df
variable
-- Select the first 10 genres from books using PostgreSQL
SELECT genre
FROM books
LIMIT 10;Explore Datasets
Use the books table to explore the data and practice your skills!
- Select only the
titlecolumn. - Alias the
titlecolumn asbook_title. - Select the distinct author names from the
authorcolumn. - Select all records from the table and limit your results to 10.