Blog Posts

Introducing SQL Set Operators: Union, Union All, Minus, and Intersect

set operators

When you need to combine information from multiple tables or queries, SQL set operators are a useful tool. SQL queries let us choose the most important bits from large amounts of information. Of course, we can’t expect that all necessary data will be stored in one table. Let’s say we want to present every aspect of some key data group in one results table (e.g. making a report with the names of every customer served by every department of a

Continue Reading

Useful SQL Patterns: Date Generator

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. SQL patterns, such as the pivot pattern we discussed last week, can save you a lot of time and effort. Suppose you are asked to get a range of days in a financial quarter, but the only records you have are for

Continue Reading

Useful SQL Patterns: Pivoting

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. Pivoting in SQL refers to taking the data in table rows and making that data into columns. This is very important in reporting, and it’s easy to do when you use the CASE statement. In fact, you will see that pivoting data

Continue Reading

Learning SQL JOINs Using Real-Life Situations

The JOIN statement lets you work with data stored in multiple tables. This article is a practical introduction to the SQL JOIN. Imagine if you could only work with one database table at a time. Fortunately, this isn’t anything we have to worry about. Once you learn the JOIN statement, you can start linking data together. This article will give you examples that illustrate how we use JOINs, how each type of JOIN works, and when to use each type.

Continue Reading

Useful SQL Patterns: Conditional Summarization with CASE

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. Previously, we looked at the SQL pattern of matching NULLs. This is important when you are comparing columns containing NULL values. Today, we’re going to consider another SQL practice: conditional summarization with CASE operator. What is Conditional Summarization? When you are using

Continue Reading

Using CASE with Data Modifying Statements

What happens when you combine CASE with SQL’s data modifying statements? Find out in this article. The CASE expression is a very useful part of SQL and one that you’ll employ frequently. We’ve already covered what the CASE expression does, how to format it, and how to use it in a SELECT statement in “Using CASE to Add Logic to a SELECT”. Another article, “How to Sort Records with the ORDER BY Clause” demonstrated how to use CASE in an

Continue Reading

GET ACCESS TO EXPERT SQL CONTENT!