This page allows you to practice SQL online, and provides more than 200 different SQL exercises and solutions. This platform is also accompanied by a self-study guide, which offers comprehensive coverage of the SQL language, in a detailed, logical and well organized manner.

We hope you’ll find this page useful and effective.

Ram Kedem and Elad Peleg.

 

In General :

  • Use this section to practice Microsoft / Oracle related SQL exercises
  • The Microsoft related tutorials / exercises can found in this link
    The Oracle related tutorials / exercises can be found in this link
  • To download the databases used in these exercises, use one of the following links: [ACDB] [HR]
  • Please note – Exercises performed on the online environment, might return less results than those performed on your local environment (by downloading ACDB or HR to your local machine). The platform I used to create this online SQL practice has a limit for the maximum number of rows in each database, therefore in each table you’ll find only sample rows of data.

How To :

Rextester stands for regular expression tester. Using Rextester.com you’ll be able to issue online queries against Microsoft / Oracle databases.

Working with this platform is quite easy, use the following link to access the online SQL editor, use the top-left drop down list to choose your platform.

 

Once you’re there, copy the contents of either [ACDB] or [HR] scripts:

 

And that’s it, you’re ready to go. Issue any query against the database. (Type your query at the bottom of the script)

The following questions allow you to practice SQL online using the Stack Overflow Data Explorer.

The Stack Overflow Data Explorer is a free utility allowing you to learn SQL interactively by querying the data of Stack Overflow Q&A for programmers.

 

sql practice online

 

Very important
Most of the tables of Stack Overflow Data Explorer contain great amount of rows. Querying the whole table will slow you down significantly, and most importantly – will overload the database server.
Please, use the TOP command in every SQL statement you issue, and retrieve back only partial results.
You will be reminded to so that in every exercise 🙂

 

Chapter 1 - Basic SQL Select Statments

Practice SQL Online – Basic SQL Select Statments

 

  1. Create a query to display all data from the Posts table. Remember to use TOP 20.
  2. Create a query to display all the data from the Users table. Remember to use TOP 20.
  3. The following SELECT statement executes successfully (True / False)
    FROM Posts
    SELECT PostTypeId, AnswerCount
    
  4. Create a query to display the AnswerCount, ViewCount, and Title. Name the last column (Title) heading as “Post Title” (Posts table). Remember to use TOP 20.
  5. The following SELECT statement executes successfully (True / False)
    SELECT TOP 20 Id, Views, Views
    FROM Users
    
  6. The following SELECT statement executes successfully (True / False)
       
    SeleCT TOP 20 PostTypeId, AnswerCount, 
    FROM Posts
    
  7. Create a query to display the post id, ViewCount, Title, AnswerCount and CreationDate (Posts table). Remember to use TOP 20.
  8. Create a query to display the Title, Body, CreationDate, AnswerCount, and FavoriteCount after an addition of 20%. Name the last column (FavoriteCount after the addition) heading as “New Count” (Posts table). Remember to use TOP 20.
  9. Create a query to display the Body concatenated with the Title, separated by space, and the literal ‘Tag List : ‘ concatenated with the values of Tags column. Name the column headings “Post Details” and “Tags” respectively (Posts table). Remember to use T0P 20.
  10. Create a query to display the unique PostTypeId from Posts table.
  11. Create a query to display the Body concatenated with Tags column, separated by space. Name this column heading as “Body and Tags” (Posts table). Remember to use TOP 20.
  12. Create a query to display the Title, Body, and AnswerCount, also display the Score column concatenated with the literal string “SCn”, separated by space. Name the column headings “TL”, “BD”, “AC”, and “SC” respectively (Posts table). Note that the Score column datatype is numeric, and in order to concatenate it with a string you need to use the CAST function. Remember to use TOP 20.
  13. Create a query to display the unique ReviewTaskTypeId in ReviewTasks table. TOP statement cannot be used in this exercise.

Would you like to read more?