Feature Course of the Month – SQL Advanced Queries


If you know the basics of SQL you might want to develop your knowledge of SQL a little further to build more complex queries.

If you are familiar with inner, and outer joins you may well find that  this is not enough to extract what you need, or that you may need to do a couple of basic queries which you then export to Excel to analyse it there.

However, one of the more powerful querying techniques is to use subqueries.  The basic principle of subqueries is that you can extract information from a query and use the output of that query in another one.  This means you can extract a set of data which you then link to more data to get your final result.

If you think about normal inner joins for instance, if you use these across more than two tables, you tend to very quickly cut down on the number of returned values because the likelihood of common values existing across three or more tables tends to diminish very quickly.  By creating subqueries you can extract larger intermediate data sets and link the two or more data sets returned by your subqueries into a more meaningful overall query.

Combine this with union or union all type queries, include variables in the mix as well as conditional statements, you can start to build fairly complex queries that are able to extract what you really want rather than limiting yourself to common values found through the more common inner join type query.

If you need to take your SQL knowledge and skills to the next level we run an SQL Advanced Queries course.  Covering how to create and use stored procedures, use conditional statements in queries, work with variables and parameters, create looping routines and of course the subqueires I have been talking about in the blog then this is the course for you.

For more information or to book a place on our next course please feel free to contact us by email on hellolearning@uk.thalesgroup.com or give us a call on 0370 218 8851.

Next dates 8-9 November 2017.

Written by Richard Harker, Technical and Digital Learning Consultant.