Exercise 1: Selecting All Columns from A Table
Exercise: Select all data from the table distribution_companies.
Solution: Solution explanation: Select the data using the SELECT statement.
To select all the columns, use an asterisk (*).
The table from which the data is selected is specified in the FROMclause.
Solution output:
,
Exercise 2: Selecting A Few Columns from A Table
Exercise:For each movie, select the movie title, the IMDb rating, and the year the movie was released.
Solution: Solution explanation: List all the columns needed (movie_title, imdb_rating, and year_released) in the SELECT statement, separated by the comma.
Reference the table movies in the FROMclause.
Solution output:
,
Exercise 3: Selecting A Few Columns and Filtering Numeric Data in Where
Exercise: Select the columns movie_title and box_office from the table movies. Show only movies with earnings above $300 million.
Solution: Solution explanation: List the columns in SELECT and reference the table in FROM.
Use a WHERE clause to filter the data – write the column box_office and use the ‘greater than’ operator (>) to show only values .
,
Exercise 4: Selecting A Few Columns and Filtering Text Data in Where
Exercise: Select the columns movie_title, imdb_rating, and year_released from the table movies.
Show movies that have the word ‘Godfather’ in the title.
Solution: Solution explanation: List the columns in SELECT and reference the table in the FROM clause.
Use a WHERE clause to filter the data.
After writing the column name, use the LIKE logical ope.
,
Exercise 6: Filtering Data Using Where and Sorting The Output
Exercise: Select the columns movie_title, imdb_rating, and year_released from the table movies.
Show movies released after 1991.
Sort the output by the year released in ascending order.
Solution: Solution explanation: List the columns in SELECT and reference the table in FROM.
Filter the data with WHERE by applying the ‘greater than’ operator to th.
,
Exercise 7: Grouping Data by One Column
Exercise:Show the count of movies per each language category.
Solution: Solution explanation: Select the column language from the table movies.
To count the number of movies, use the aggregate function COUNT().
Use the asterisk (*) to count the rows, which equals the count of movies.
To give this column a name, use the AS keyword followed by the de.
,
Exercise 8: Grouping Data by Multiple Columns
Exercise:Show the count of movies by year released and language.
Sort results by the release date in ascending order.
Solution: Solution explanation: List the columns year_released and language from the table movies in SELECT.
Use COUNT(*) to count the number of movies and give this column a name using the AS keyword.
Specify the columns by which y.
,
Exercise 9: Filtering Data After Grouping
Exercise:Show the languages spoken and the average movie budget by language category.
Show only the languages with an average budget above $50 million.
Solution: Solution explanation: Select the column language from the table movies.
To compute the average budget, use the aggregate function AVG() with the column budget in parentheses.
Name the colu.
,
How can i Improve my SQL practice online?
What changes is the complexity of the problems you solve and of the code you write.
Look for more challenges in the SQL Basics course and the Monthly SQL Practice track.
Both are excellent for your SQL practice online.
This is true, especially if you do not have an opportunity to use SQL on a daily basis in your job.
,
How do I learn SQL?
SQL statements are used to retrieve and update data in a database.
The best way we learn anything is by practice and exercise questions.
We have started this section for those (beginner to intermediate) who are familiar with SQL.
Hope, these exercises help you to improve your SQL skills.
,
The Dataset
The question is always where to find data for practicing SQL.
We’ll use our dataset for all exercises.
No need to limit yourself to this, though – you can find other free online datasets for practicing SQL.
Our dataset consists of two tables.
The table distribution_companieslists movie distribution companies with the following columns: 1. id– The I.
,
What is ArtBase & how does it work?
withdata baste.
Your oldloveis stillthere, however,soyousetup a databasecompany, ArtBase, that builds a product for art galleries.
The core of this product is a database with a schema that captures all the information that galleries need to maintain.
,
What is SQL & how does it work?
What is SQL.
SQL stands for Structured Query Language and it is an ANSI standard computer language for accessing and manipulating database systems.
It is used for managing data in relational database management system which stores data in the form of tables and relationship between data is also stored in the form of tables.
Clay problem about the set of rational solutions to equations defining an elliptic curve
In mathematics, the Birch and Swinnerton-Dyer conjecture describes the set of rational solutions to equations defining an elliptic curve.
It is an open problem in the field of number theory and is widely recognized as one of the most challenging mathematical problems.
It is named after mathematicians Bryan John Birch and Peter Swinnerton-Dyer, who developed the conjecture during the first half of the 1960s with the help of machine computation.
As of 2023, only special cases of the conjecture have been proven.