
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Welcome to my course on the basic structure of the SELECT statement in SQL. As SQL is desired more and more in the modern workplace, even in non-IT areas, it is more important to become familiar with this language and its tools. If you have never seen the database interface for writing SQL, or if you use SQL daily but do not really understand what you are copying and pasting in the query, or if you feel confident enough but just want to make sure you have covered any gaps, this course will provide a foundation to grow in your understanding of getting data out of databases using SQL.
If you are familiar with Excel (or any spreadsheet application), you already have conceptual knowledge that can be easily translated toward understanding databases. Learn about the similarities, and comprehend the organization and logic used to store data.
Relational Database Management Systems (RDBMS) are user interfaces that allow you to interact with a database. You can put the same tables in multiple management systems and oftentimes take a simple statement from one and run it in another. You also can sometimes connect to each of the management systems using the querying tool from only one of them.
Learn how to search for free data available for download that can then be used in a database.
Good practices for searching the Web for help with databases and with SQL
Hear a brief history of the development of SQL and the institutions that have provided its standardization. Learn where SQL falls in the families of coding languages, and see some of the main variants that have been developed over the years.
When selecting fields from the database, all that is needed in the query statement are the SELECT and FROM clauses with their corresponding details, the one to specify which fields, and the other to specify from which database objects, typically tables or views. This lesson covers these two most basic clauses and also provides an introduction to the mechanics of interacting with the user interfaces we use to write and execute SQL queries.
FILTERING
When you want to view only a subset of records, such as only those for a particular carrier, the WHERE clause allows you to filter your result set. You specify a particular value (or values) that you want to keep (or exclude), and all that is returned are the records with those characteristics.
ORDERING
With the ORDER BY clause, you can arrange the records so that you can more easily see trends.
GROUP BY allows you to specify the categories by which you want to aggregate the data in order to summarize the information, and HAVING lets you limit the results of the aggregated values.
As a technical aside, we discuss why companies use Development, Test, and Production environments. We also look at the differences between databases using an OLTP structure and an OLAP structure. We end with a quick overview of the metadata queries available in several RDMBS applications.
When you need to filter or limit the result set by criteria in more than one field, or negate the criteria, conjunctions allow you to string together multiple conditions to achieve those results.
The CASE statement lets you modify your result set without making changes to the underlying data in the source tables. Arranged in one of two general forms, it runs the data through conditions to make updates that will flow through to the final results. You can insert it into any clause of the SELECT statement as if it were just another field in the table.
Understanding JOINs is essential for querying a database. Most information you will need will be spread across multiple tables, and JOINs pull this data together more efficiently than other methods. The INNER, the LEFT, RIGHT and FULL OUTER, and the CROSS JOINs connect data tables in different ways in order to provide the set of data fields and records needed.
Applying a consistent style will improve your SQL code's readability and clarity. Learning how to use aliases well and when and where to add comments goes a long way to making your code more user-friendly.
When you have more than one data table with similar fields and with records that are clearly split into separate tables, set operators will combine these data subsets into one set. UNION, INTERSECT, and EXCEPT/MINUS combine the record sets, merging duplicates when desired.
Use subqueries to build smaller query blocks that are arranged to generate larger, more complex queries. Be careful to not substitute a subquery for a more efficient method, but make use of these to better organize the query logic and to avoid the impulse to create a table or view to encapsulate the temporary need for data. Subqueries are a powerful technique that enhances the query's modularity.
We'll take a look back at all we covered in this course.
A lot more can be done with SQL. This provided some of the basics. Come again and be on the lookout for my other courses!
The tools of business continue to change and grow. Long ago, paper and pencil replaced rote memory and more recently were themselves replaced by computers. Analysts used to work out calculations on calculators, then switched to spreadsheet applications, like Excel. Understanding SQL used to be a skill reserved for IT personnel; now, SQL is becoming an indispensable analytical tool in the modern workplace. Just like spreadsheets were once a tool known only to specialists but are now ubiquitous in the workplace, likewise SQL is beginning to become more accessible throughout organizations.
This course focuses on the SELECT statement in SQL so stays squarely in the realm of Data Query Language (DQL) commands. Although this focus may sound limiting, understanding the SELECT statement is essential for many of the other commands, since typically the data will need to be selected first before doing something else with it. As well, many of the standard and exotic commands and functions can be easily presented with a SELECT statement, and mastery of this beginning set will prepare people for further explorations into SQL.
I learned everything I know about SQL on the job, and so can you. After teaching for 10 years, I was pulled into IT at my first corporate position and have used SQL in every role since then. I know what it is like to learn a keyword for the first time, to start exploring its uses, to be shown tricks and techniques using it by others, and to eventually gain a deeper understanding of why it works the way it does. I have trained many others in SQL in companies large and small, including some Fortune 50 companies. I have compiled my experiences and curated from those lessons what I believe to be the important initial steps to share with you. (Those of you from my past training sessions will likely recognize parts of these lessons!) I trust you will take this knowledge, and Spirit willing, share it with others.
So, without further ado, let's begin. Please click on the first lecture in section 1, the starting point to work your way through this course.