562 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
You are welcome to try any of the 129 SQL exercises listed below, but please do not distribute them in any form without asking for our written permission first.
Software: | SQL |
Topic: | Simple Queries |
Level: | Relatively easy |
Exercise: | Create a query to list out all of the events in the database, with the most recent first. |
Software: | SQL |
Topic: | Simple Queries |
Level: | Relatively easy |
Exercise: | Create a query using TOP N to show the last 3 categories in a table. |
Software: | SQL |
Topic: | Simple Queries |
Level: | Average difficulty |
Exercise: | Create a query to list the first 5 events in chronological order. |
Software: | SQL |
Topic: | Simple Queries |
Level: | Harder than average |
Exercise: | Run two SELECT queries to show the first and last events. |
Software: | SQL |
Topic: | Setting criteria using WHERE |
Level: | Relatively easy |
Exercise: | Create a query to list all of the love and relationships events. |
Software: | SQL |
Topic: | Setting criteria using WHERE |
Level: | Average difficulty |
Exercise: | Us a WHERE clause to show events which contain two given text strings. |
Software: | SQL |
Topic: | Setting criteria using WHERE |
Level: | Average difficulty |
Exercise: | Use a WHERE clause to show all of the events between two given dates. |
Software: | SQL |
Topic: | Setting criteria using WHERE |
Level: | Harder than average |
Exercise: | 3 challenging queries combining criteria to find possible data anomalies. |
Software: | SQL |
Topic: | Setting criteria using WHERE |
Level: | Harder than average |
Exercise: | Use wildcards, AND, IN and OR to get a list of events to do with water. |
Software: | SQL |
Topic: | Calculations |
Level: | Relatively easy |
Exercise: | List for each event the number of characters in its name. |
Software: | SQL |
Topic: | Calculations |
Level: | Average difficulty |
Exercise: | Cast numbers as text to allow you to concatenate them together with strings. |
Software: | SQL |
Topic: | Calculations |
Level: | Average difficulty |
Exercise: | Use IsNull, Coalesce and/or CASE WHEN to replace nulls with values. |
Software: | SQL |
Topic: | Calculations |
Level: | Average difficulty |
Exercise: | Write a CASE WHEN expression to assign countries to different groups. |
Software: | SQL |
Topic: | Calculations |
Level: | Harder than average |
Exercise: | Divide events according to whether their first/last letters are the same or vowels. |
Software: | SQL |
Topic: | Calculations |
Level: | Harder than average |
Exercise: | Use the % modulus operator and a lot of ingenuity to show how big each country is relative to Wales. |
Software: | SQL |
Topic: | Calculations |
Level: | Harder than average |
Exercise: | Use the CHARINDEX function multiple times to show the number of characters between two words in a text string. |
Software: | SQL |
Topic: | Calculations using dates |
Level: | Relatively easy |
Exercise: | Combine the YEAR, CONVERT and FORMAT functions to show events in your year of birth. |
Software: | SQL |
Topic: | Calculations using dates |
Level: | Average difficulty |
Exercise: | Use the DATEDIFF and the ABS functions to list the events in order of closeness to when you were born. |
Software: | SQL |
Topic: | Calculations using dates |
Level: | Average difficulty |
Exercise: | Use the DATENAME and DATEPART functions to show events taking place on Friday 13th of any month/year. |
Software: | SQL |
Topic: | Calculations using dates |
Level: | Harder than average |
Exercise: | Display full dates, including the correct suffix (1st, 2nd, 3rd, etc). |
Software: | SQL |
Topic: | Basic joins |
Level: | Relatively easy |
Exercise: | Create a query containing a join to list out those films whose source is NA. |
Software: | SQL |
Topic: | Basic joins |
Level: | Relatively easy |
Exercise: | Create a query using the designer, joining 2 tables, then tidy it up and comment its SQL. |
Software: | SQL |
Topic: | Basic joins |
Level: | Relatively easy |
Exercise: | Use an inner join to link two tables together in a query. |
Software: | SQL |
Topic: | Basic joins |
Level: | Average difficulty |
Exercise: | Create an inner join in a query, then change it to an outer join to show categories having no events. |
Software: | SQL |
Topic: | Basic joins |
Level: | Average difficulty |
Exercise: | Join two tables together in SQL, using alias table names. |
Software: | SQL |
Topic: | Basic joins |
Level: | Average difficulty |
Exercise: | Link the continent, country and event tables with inner joins, and then filter by fields from 2 tables. |
Software: | SQL |
Topic: | Basic joins |
Level: | Average difficulty |
Exercise: | Use inner joins to link four tables to show Dr Who enemies by author. |
Software: | SQL |
Topic: | Basic joins |
Level: | Harder than average |
Exercise: | Use an outer join and criterion to list out the countries which have no corresponding events. |
Software: | SQL |
Topic: | Basic joins |
Level: | Harder than average |
Exercise: | Use inner joins to link lots of tables together, with a WHERE clause. |
Software: | SQL |
Topic: | More exotic joins |
Level: | Average difficulty |
Exercise: | Write an SQL outer join to show unmatched records in another table. |
Software: | SQL |
Topic: | More exotic joins |
Level: | Harder than average |
Exercise: | Create 2 self-joins between a table of families and itself, to show families, their parents and their grandparents. |
Software: | SQL |
Topic: | Aggregation and grouping |
Level: | Relatively easy |
Exercise: | Use COUNT, MAX and MIN to show statistics about the rows in the events table. |
Software: | SQL |
Topic: | Aggregation and grouping |
Level: | Relatively easy |
Exercise: | Use GROUP BY and COUNT to report on the number of events for each category. |
Software: | SQL |
Topic: | Aggregation and grouping |
Level: | Relatively easy |
Exercise: | Use grouping to show how many episodes each Doctor Who author wrote. |
Software: | SQL |
Topic: | Aggregation and grouping |
Level: | Average difficulty |
Exercise: | Group by 2 fields and use HAVING clause to show popular combinations. |
Software: | SQL |
Topic: | Aggregation and grouping |
Level: | Average difficulty |
Exercise: | Use SELECT, FROM, WHERE, GROUP BY, HAVING and ORDER BY to list non-European busy countries. |
Software: | SQL |
Topic: | Aggregation and grouping |
Level: | Harder than average |
Exercise: | Combine CAST, AVG, COUNT, LEN, UPPER and LEFT to show the average length of event names by category initial. |
Software: | SQL |
Topic: | Aggregation and grouping |
Level: | Harder than average |
Exercise: | Use a complex CASE statement to show the number of events for each century, including the CUBE function. |
Software: | SQL |
Topic: | Aggregation and grouping |
Level: | Harder than average |
Exercise: | Use lots of grouping and criteria to list out year/doctor episode counts. |
Software: | SQL |
Topic: | Subqueries |
Level: | Relatively easy |
Exercise: | Use a subquery to show events which happened since the last one for a particular country occurred. |
Software: | SQL |
Topic: | Subqueries |
Level: | Relatively easy |
Exercise: | Use subqueries to filter with aggregates. |
Software: | SQL |
Topic: | Subqueries |
Level: | Average difficulty |
Exercise: | Create a correlated subquery to list out all countries having more than 8 events. |
Software: | SQL |
Topic: | Subqueries |
Level: | Average difficulty |
Exercise: | Using sub queries filter the select statement. |
Software: | SQL |
Topic: | Subqueries |
Level: | Harder than average |
Exercise: | Use two subqueries to list all events in neither the last 30 countries or the last 15 categories. |
Software: | SQL |
Topic: | Stored procedures |
Level: | Relatively easy |
Exercise: | Create a stored procedure to list Dr Who episodes featuring Matt Smith. |
Software: | SQL |
Topic: | Stored procedures |
Level: | Relatively easy |
Exercise: | Filter the select statement, only show events occuring in August. |
Software: | SQL |
Topic: | Stored procedures |
Level: | Relatively easy |
Exercise: | Write a basic procedure to list countries in Asia, then make small changes to it. |
Software: | SQL |
Topic: | Stored procedures |
Level: | Average difficulty |
Exercise: | Create a stored procedure to list Dr Who episodes written by Steven Moffat. |
Software: | SQL |
Topic: | Stored procedures |
Level: | Harder than average |
Exercise: | Create a stored procedure to list Dr Who episodes by frequency in two ways. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Relatively easy |
Exercise: | Get a stored procedure to list the Dr Who episodes for a given enemy. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Average difficulty |
Exercise: | Create a procedure to list out the companions for a given doctor. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Average difficulty |
Exercise: | Create a stored procedure to list Dr Who episodes for a series number, using a default parameter value. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Average difficulty |
Exercise: | Create a stored procedure with NULLs as the default values. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Average difficulty |
Exercise: | Create stored procedures with default values for the parameters. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Average difficulty |
Exercise: | Filter in a stored procedure using a parameter. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Average difficulty |
Exercise: | Use an output parameter to return a list variable of the most eventful continents. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Average difficulty |
Exercise: | Use return values to bring back an INT return value from a stored procedure. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Harder than average |
Exercise: | Count rows and pass the information out of a procedure using output parameters. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Harder than average |
Exercise: | Return a continent name from one procedure, and pass the output value into another. |
Software: | SQL |
Topic: | Parameters and return values |
Level: | Harder than average |
Exercise: | Return from a stored proecure the name of the country with the most events and how many events there were. |
Software: | SQL |
Topic: | Testing conditions |
Level: | Average difficulty |
Exercise: | Use IF to change the SELECT statement that a stored proc runs. |
Software: | SQL |
Topic: | Scalar functions |
Level: | Relatively easy |
Exercise: | Count the number of letters for an event using a scalar function. |
Software: | SQL |
Topic: | Scalar functions |
Level: | Relatively easy |
Exercise: | Use a scalar function to include each Dr Who's incarnation dates in a query. |
Software: | SQL |
Topic: | Scalar functions |
Level: | Average difficulty |
Exercise: | Create a function to take in any month number and return the month name. |
Software: | SQL |
Topic: | Scalar functions |
Level: | Average difficulty |
Exercise: | Use an SQL function within a query to find out the part number of any Dr Who episode. |
Software: | SQL |
Topic: | Scalar functions |
Level: | Harder than average |
Exercise: | Create all sorts of scalar functions in SQL to return info about Dr Who episodes from within a query. |
Software: | SQL |
Topic: | Scalar functions |
Level: | Harder than average |
Exercise: | Use a CASE statement to classify each event according to whether it is the top of its class or not. |
Software: | SQL |
Topic: | Transactions |
Level: | Relatively easy |
Exercise: | Create a transaction, add Shaun the Sheep as a Doctor Who, then commit or roll this back. |
Software: | SQL |
Topic: | Transactions |
Level: | Average difficulty |
Exercise: | Create a transaction to update all countries that aren't your own, then roll it back. |
Software: | SQL |
Topic: | Transactions |
Level: | Average difficulty |
Exercise: | Create a transaction which prevents the same event being added multiple times. |
Software: | SQL |
Topic: | Transactions |
Level: | Average difficulty |
Exercise: | Update the number of Dr Who enemies within a transaction, and commit or roll this back. |
Software: | SQL |
Topic: | Transactions |
Level: | Average difficulty |
Exercise: | Use the Insert, Update and Delete commands in a single transaction. |
Software: | SQL |
Topic: | Creating tables |
Level: | Average difficulty |
Exercise: | Create a table of genres for books using CREATE TABLE, then insert a few rows using INSERT INTO. |
Software: | SQL |
Topic: | Creating tables |
Level: | Average difficulty |
Exercise: | Has mistake must fix spelling of millenium!!!!. |
Software: | SQL |
Topic: | Creating tables |
Level: | Average difficulty |
Exercise: | Store useful information about continents in a new permanent table. |
Software: | SQL |
Topic: | Creating tables |
Level: | Average difficulty |
Exercise: | Write a SQL query to create a table of companies, and add two rows to it. |
Software: | SQL |
Topic: | Creating tables |
Level: | Harder than average |
Exercise: | Create a table of genres for books, and create a foreign key constraint linking this to a table of authors. |
Software: | SQL |
Topic: | Temporary tables and table variables |
Level: | Relatively easy |
Exercise: | Declare a table variable, and copy the Dr Who companions, enemies and doctors into it. |
Software: | SQL |
Topic: | Temporary tables and table variables |
Level: | Relatively easy |
Exercise: | Try both methods of creating Temporary tables, using INTO and CREATE. |
Software: | SQL |
Topic: | Temporary tables and table variables |
Level: | Relatively easy |
Exercise: | Write SQL to put Dr Who rows in a temporary table, and add companions and enemies into this. |
Software: | SQL |
Topic: | Temporary tables and table variables |
Level: | Average difficulty |
Exercise: | Add rows one by one within a loop into a temporary table that you've created. |
Software: | SQL |
Topic: | Temporary tables and table variables |
Level: | Average difficulty |
Exercise: | Use a table variable to hold useful information from several sources together. |
Software: | SQL |
Topic: | Temporary tables and table variables |
Level: | Average difficulty |
Exercise: | Use a table variable to join one set of data to another table. |
Software: | SQL |
Topic: | Temporary tables and table variables |
Level: | Average difficulty |
Exercise: | Use a temporary table or table variable to combine the best Doctor Who episodes into a single table. |
Software: | SQL |
Topic: | Temporary tables and table variables |
Level: | Harder than average |
Exercise: | Use a table variable or temporary table to build up a list of database problems in a single table. |
Software: | SQL |
Topic: | Temporary tables and table variables |
Level: | Harder than average |
Exercise: | Write the names of your stored procedures and functions to a temporary table or table variable. |
Software: | SQL |
Topic: | Table-valued functions |
Level: | Relatively easy |
Exercise: | Create a table-valued function to list events for a given year. |
Software: | SQL |
Topic: | Table-valued functions |
Level: | Relatively easy |
Exercise: | List episodes made by any given doctor by using a table function in SQL. |
Software: | SQL |
Topic: | Table-valued functions |
Level: | Average difficulty |
Exercise: | Create an inline tabled valued function taking two parameters. |
Software: | SQL |
Topic: | Table-valued functions |
Level: | Average difficulty |
Exercise: | Return a table of episodes for a series number and author, using a table-valued function. |
Software: | SQL |
Topic: | Table-valued functions |
Level: | Harder than average |
Exercise: | Show episodes, listing companions or enemies according to parameter, using an MSTVF function. |
Software: | SQL |
Topic: | Table-valued functions |
Level: | Harder than average |
Exercise: | Use a MSTVF to show categories, countries and continents that contain a given vowel. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Relatively easy |
Exercise: | Create an expression in a common table expression, and group by this in a query using the CTE. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Relatively easy |
Exercise: | Use a Common Table Expression to write a complex query in two distinct parts. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Relatively easy |
Exercise: | Use a CTE to group a query by a CASE expression without including it twice. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Average difficulty |
Exercise: | Create a CTE to show - amazingly easily - events containing the words THIS and THAT, in this order. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Average difficulty |
Exercise: | Show enemies appearing in chosen episodes, using a Common Table Expression (CTE). |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Average difficulty |
Exercise: | Use a basic CTE to hold filtered data before joining onto another table. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Average difficulty |
Exercise: | Use a derived table to hold a select statement. Then join another table on. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Average difficulty |
Exercise: | Use linked CTEs to show continents having many countries but few events. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Harder than average |
Exercise: | Create a CTE - common table expression - to display breadcrumbs using recursion. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Harder than average |
Exercise: | Cretae two CTEs to hold data before joining them together. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Harder than average |
Exercise: | For each combination of the top 3 categories and top 3 countries, count the number of events using CTEs. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Harder than average |
Exercise: | Use a series of CTEs to show categories for countries for events not containing the letters OWL. |
Software: | SQL |
Topic: | Derived tables and CTEs |
Level: | Harder than average |
Exercise: | Use common table expressions, subqueries or any other technique to solve a complex query. |
Software: | SQL |
Topic: | Dynamic SQL |
Level: | Relatively easy |
Exercise: | Create a stored procedure which can change the name of the table in the FROM clause. |
Software: | SQL |
Topic: | Dynamic SQL |
Level: | Average difficulty |
Exercise: | Create a query which selects whatever columns, sort order and table you pass in as parameters, using dynamic SQL. |
Software: | SQL |
Topic: | Dynamic SQL |
Level: | Average difficulty |
Exercise: | Write a procedure using EXEC which varies the sort column according to the parameter value passed. |
Software: | SQL |
Topic: | Dynamic SQL |
Level: | Harder than average |
Exercise: | Using a comma-delimited list variable filter another select statement using dynamic SQL. |
You can search our full list of SQL exercises here. Or why not learn to do them the right way on one of our SQL training courses? You can attend our online training classes wherever you are in the world!
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2023. All Rights Reserved.