Problem You want to round up to the nearest integer. Background Suppose you have a list of final sales amount that you

Read More
How to Round Up to Nearest Integer

Recently a student asked me how he could calculate a Moving Median.  It’s not as easy as you think, as SQL doesn’t

Read More
Calculate Moving Median in SQL

Problem You need use SQL to calculate the Median of a result from SQL Server. Background Suppose you need to calculate the

Read More
Use SQL to Find the MEDIAN

Problem You need to avoid SQL divide by zero errors. Suppose you need to calculate velocity using the formula v = s

Read More
How to Avoid SQL Divide by Zero

Problem Given a date, you want to subtract 30 days in the past using SQL. Said another way, get the date thirty

Read More
How to Subtract 30 Days from a Date using SQL

Problem You need to figure out the week number from date, assuming Monday is the first day of the week using PostgreSQL,

Read More
How to Find the Week Number in PostgreSQL, MySQL, and SQL Server

Problem You want to replace all occurrences of a substring with a new substring using PostgreSQL, MySQL, or SQL Server. Background The

Read More
Replace using PostgreSQL

In this article we are going to design and create a sample relational database you can use with MySql, PostgreSQL or Microsoft

Read More
Database Design In Four Steps – Build the Sample PizzaDB

You can use the SQL CREATE TABLE command to create a new table in the database.  When you create a table you

Read More
CREATE TABLE SQL

Problem You want to use today’s date in your SQL query, but don’t want to type it in each day. Solution You

Read More
How to Get Today’s Date

How to Get a Date 30 Days into the Future. Problem You want to calculate a date 30 days into the Future

Read More
How to Get a Date 30 Days into the Future using SQL

In this article I’ll show you how to use STRING_SPLIT() to join two tables.  I call this the impossible join. I’ve come

Read More
How to do an Impossible Join with String Split

Sooner or later, you want to know when a column contains in SQL another value.  In this article we’ll go over several

Read More
Contains in SQL

What is a Database Trigger? A SQL trigger is special stored procedure that is run when specific actions occur within a database. 

Read More
What is a SQL Trigger?

Use SQL HAVING to filter summary results from a GROUP BY.  It specifies the search condition for the group or aggregate. SQL

Read More
SQL HAVING Tutorial

Use the SQL GROUP BY Clause is to consolidate like values into a single row.  The group is a set of columns. The group

Read More
SQL GROUP BY Guide

The SQL SUM function returns the total value within a table or group. In its simplest use, SUM() totals a column for all results and returns a

Read More
SQL SUM Function

In this article learn when to use WHERE and HAVING.  Both perform similar functions, but for different purposes! All the examples for

Read More
What is the difference between WHERE and HAVING clauses?

In this article you’ll learn to use the LIKE operator in your SQL. In most situations you’ll find yourself using LIKE within

Read More
SQL WHERE LIKE

In this video we’ll walk you though how to use the LIKE clause.   We’ll show you how to you can perform

Read More
How do I use the Like Clause in SQL Server?

In today’s lesson, you’re going to learn how to filter query results using the SQL WHERE clause.  This clause is important as

Read More
SQL WHERE – Guide and Examples

The SQL ORDER BY clause is used to sort your query result in ascending or descending order. Once you have written a

Read More
Use SQL ORDER BY to Sort Results

Both TOP and OFFSET & FETCH can be used to limit the number of rows returned.  OFFSET and FETCH can return similar

Read More
What is the Difference between TOP and OFFSET & Fetch?

In this article we explore the OFFSET and FETCH clauses.  OFFSET and FETCH are used in conjunction with the SELECT statement ORDER

Read More
Using OFFSET and FETCH with the ORDER BY clause

Some times you just need to use SQL TOP to reduce the number of rows shown in your result. This is handy

Read More
SQL TOP