The SQL Coalesce Function: Handling Null Values

coalesce, NULL, sql null, sql coalesce, coalesce oracle, coalesce vs isnull, coalesce db2, coalesce teradata, coalesce example, coalesce vs nvl, coalesce in hive, coalesce mysql

Though the COALESCE function may seem complex, it’s actually very straightforward and useful. In this short article, we’ll look at several examples of how the COALESCE function can be used to work with NULL values in SQL. The Need for Coalesce Before we dive into the COALESCE function in detail, you should understand how NULL values behave in expressions. Simply put, a value of NULL indicates that there is currently no value for a particular entry in a table column.

Continue Reading

How Often Employees Are Running Late: Datetime And Interval Arithmetic in SQL

Computing Tardiness: Date, Time, and Interval Arithmetic in SQL In this article, we’re going to discuss some interesting operations we can perform with date-related data types in SQL. The SQL standard, which most relational databases comply with these days, specifies the date-related data types that must be present in relational databases. The most important of such data types are date, time, timestamp, and interval. Here’s a brief rundown of the differences between these data types: date: represents a single day

Continue Reading

Learn SQL Views in 30 Minutes

Views aren’t complicated – if you’ve got half an hour, we’ll get you started writing SQL queries using views! Let’s start by answering the question “What is a view in SQL?’. A view is a database object (as is a table, an index, or a stored procedure). Like a table, you can query a view and extract the information in it. It can be used in the FROM clause of a SELECT, and you can reference view columns in clauses

Continue Reading

SQL Window Functions By Explanation

In our previous post, we explained how SQL window functions work by example. We started with some very simple, basic functions. Let’s extend it by explaining subclauses in window functions. SQL window functions are a great way to compute results from a set of rows rather than a single row. As you know from our first article, the “window” in window function refers to the set of rows. We showed you some examples of simple window functions like RANK and

Continue Reading

SQL Window Functions by Example

Interested in how SQL window functions work?  We use some simple examples to get you started. SQL window functions are a bit different; they compute their result based on a set of rows rather than on a single row. In fact, the “window” in “window function” refers to that set of rows. Window functions are similar to aggregate functions, but there is one important difference. When we use aggregate functions with the GROUP BY clause, we “lose” the individual rows.

Continue Reading

GET ACCESS TO EXPERT SQL CONTENT!