Skip to content
Basic SQL - Book titles
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.
-
- select all records. AS [after SELECT --- (name of column)] - to change the name of the column. SELECT DISTINCT - it only selects distinct attributes from the mentioned column. LIMIT --- (no. of observation you need) - to select records from the table that limits it to the number you mentioned.
Understand the dataset
DataFrameas
books
variable
-- Add your own queries here
SELECT *
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.
DataFrameas
df
variable
SELECT DISTINCT author, title as book_title
FROM books
LIMIT 10;
Unknown table
- Select book titles that starts with 'The'
DataFrameas
df2
variable
SELECT author, genre AS book_genre, title as book_title
FROM books
WHERE title LIKE 'The%';- Look for Stieg Larsson
- Identify the count of books for each genre and the year their books was published
DataFrameas
df9
variable
SELECT author, genre, year, COUNT(*) AS book_count
FROM books
WHERE author = 'Stieg Larsson'
GROUP BY author, genre, year
ORDER BY book_count DESC
LIMIT 10;- Find out which author has most books published
- Limit it to 10 records
DataFrameas
df5
variable
SELECT author, COUNT(*) AS book_count
FROM books
GROUP BY author
ORDER BY book_count DESC
LIMIT 10;