An Overview of Aggregate Functions in SQL by Tihomir Babic 7 Jan 2021 Aggregate functions are commonly used in SQL. This article will lead you through their use and show examples of how they work. SQL aggregate functions are a useful tool, especially for creating reports. They’re not difficult to understand, especially if you have some experience with Excel or similar programs. You’ve probably used aggregate functions like SUM or AVERAGE in a spreadsheet. Even if you only occasionally use them, knowing aggregate functions can help you better understand your data and work more efficiently. Read more SQL JOIN Tips for Beginners by Tihomir Babic 1 Jan 2021 If you’re a beginner and want to know how to start using SQL JOINs in your queries, you’ve come to the right place. Using the SQL JOIN clause is necessary if you want to query multiple tables. Sooner or later, you’ll have to use more than one table in a query. It’s the nature of relational databases in general – they consist of data that’s usually saved in multiple tables; in turn, these form a database. Read more How to Use CASE WHEN With SUM() in SQL by Tihomir Babic 15 Dec 2020 This article will teach you what a CASE WHEN expression is in SQL and how to use it with a SUM() function and a GROUP BY statement. The examples are included to bolster your understanding. Knowing how to use a CASE WHEN expression in SQL adds insight into the exciting possibilities in SQL. It elevates you from a simple user who depends on what SQL returns, to a user who is more in command and who sets specific criteria in SQL. Read more How to Find All Employees Under Each Manager in SQL by Tihomir Babic 25 Nov 2020 Have you ever been tasked with building an organizational chart – i.e. finding the employees under each manager in a company? In SQL, you can do that easier than you think! This article will show you how to get the answer using a recursive query. In the business world, it’s a very common task to list all the subordinate employees for a given manager. Is doing this hard enough to warrant a whole article? Read more What is the Difference Between COUNT(*), COUNT(1), COUNT(column name), and COUNT(DISTINCT column name)? by Tihomir Babic 29 Oct 2020 Have you noticed there are different variations of the SQL COUNT() function? This article explains the various arguments and their uses. As a SQL user, you’re probably quite familiar with the COUNT() function. Even though it’s relatively simple, it can be used in several different ways. Each way has a very different use. I imagine you’ve seen code that contains the function COUNT(*) or COUNT(1). You’ve probably also seen some other uses of the COUNT() function, such as COUNT(column name) and COUNT(DISTINCT column name), even if you haven’t used them. Read more What are SQL CTE Best Practices? by Tihomir Babic 28 Oct 2020 Are you wondering what the best practices for using common table expressions are? This article will help you learn when to use a CTE and how to write it. If you have heard about SQL CTEs, you have probably noticed they’re often mentioned together with subqueries. Sometimes, people think there’s no difference compared to the subqueries, and there’s often debate about whether a CTE or subquery should be used to get a particular result. Read more Six Window Function Templates to Save in Your Code Editor by Tihomir Babic 29 Sep 2020 Do you use window functions often enough to know them well but not often enough to remember all the details? Here are six window function codes you should save as templates. Window functions are a handy SQL option, but it doesn’t mean you use them all the time. Maybe you only use them occasionally; if that’s the case, you probably find yourself needing to refresh your memory every time you use them. Read more How to Use 2 CTEs in a Single SQL Query by Tihomir Babic 17 Sep 2020 Have you ever wondered how to use multiple CTEs in one SQL query? Read this article and find out about recursive CTEs. After learning common table expressions or CTEs, a natural question is “Can I use several CTEs in one query?” Yes, you can! And you can do it quite easily, especially if you already have some basic knowledge of CTEs. Whether you know a bit about CTEs or you’re entirely new to the CTE world, reading about what a CTE is is always a good start. Read more How to Calculate the Length of a Series with SQL by Tihomir Babic 25 Aug 2020 What is a time series and why bother to calculate its length using SQL? How do we calculate the length of a series in SQL? I can answer that in two words: window functions! Yes, you’ll need some knowledge of SQL window functions to calculate series length. But what is a time series, and why would you want to find out how long it is? What Is a Series? Read more Who Should Learn SQL Window Functions? by Tihomir Babic 5 Aug 2020 Do you want to learn how SQL window functions can help you at your job? This article will show you examples from various business applications where they can be very useful. I won’t be explaining what SQL window functions are in this article, but rather how to use them. If you’re not familiar with window functions or their syntax, don’t worry. Here’s an article that can help you with an introduction to SQL window functions. Read more «« « 1 2 » »»