Skip to content

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

Spinner
DataFrameas
books
variable
-- Add your own queries here
SELECT * 
FROM books

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.

Question 1:

Write SQL code that returns a result set with just one column listing the unique authors in the books table.

Spinner
DataFrameas
df
variable
SELECT DISTINCT author 
FROM books

Question 2

Update the code to return the unique author and genre combinations in the books table.

Spinner
DataFrameas
df1
variable
SELECT DISTINCT author, genre
FROM books;

Questions 3

Add an alias to the SQL query to rename the author column to unique_author in the result set.

Spinner
DataFrameas
df2
variable
SELECT DISTINCT author AS unique_author
FROM books

Question 4

Using PostgreSQL, select the genre field from the books table; limit the number of results to 10.

Spinner
DataFrameas
df3
variable
SELECT genre 
FROM books 
LIMIT 10;