18 Aug 2021 Kateryna Koidan 5 Practical SQL CTE Examples Common table expressions (CTEs) were introduced into SQL to improve the readability and the structure of SQL queries, especially those requiring multiple steps to get the necessary output. In this article, we will go through several examples to show how SQL CTEs can help you with complex calculations and hierarchical data structures. Common Table Expressions in SQL Common table expressions (CTEs), also called WITH clauses, allow creating named subqueries that are further referenced in the main query. Read more 22 Jul 2021 Kateryna Koidan What Is the Difference Between WHERE and ON in SQL JOINs? When you join tables in SQL, you may have conditions in an ON clause and in a WHERE clause. Many get confused by the difference between them. In this article, we will discuss this topic by first reminding you the purpose of the ON and WHERE clauses then by demonstrating with examples which types of conditions should be in each of these clauses. Both the ON clause and the WHERE clause can specify conditions. Read more 15 Jul 2021 Kateryna Koidan 5 Reasons Why You Should Use CTEs Instead of Subqueries Common Table Expressions, or CTEs, were introduced in SQL:1999 to handle cases where the output of one query is used within another query. But didn’t we already have subqueries for this? In this article, I’ll demonstrate with multiple examples why CTEs are better than subqueries for the structure and readability of your SQL queries. Let’s start by reminding ourselves what CTEs and subqueries are and how they differ. Common Table Expressions vs. Read more 23 Jun 2021 Kateryna Koidan Do You Need to Learn SQL To Become a Programmer? SQL is primarily used by database administrators (DBAs), business analysts, and data analysts. But what about other programming roles? In this article, I’ll show how software engineers, web developers, and app developers use SQL and why you need to learn SQL to become a programmer. Like many other aspiring programmers, you are probably wondering “Do I need SQL?”. To answer this question, you should know that you’ll encounter data everywhere in software development. Read more 9 Jun 2021 Kateryna Koidan 4 Ways to Learn Which JOIN to Use in a SQL Query You probably already know that you should use JOIN to combine data from several tables. But what kind of JOIN? In this article, I’ll introduce four simple ways to finally learn which JOIN to use in different scenarios. Before we jump into smart strategies for learning SQL JOINs, I suggest taking a brief overview of the major JOIN types. We’ll go through several examples to recall the difference between (INNER) JOIN, LEFT (OUTER) JOIN, RIGHT (OUTER) JOIN, and FULL (OUTER) JOIN. Read more 13 May 2021 Kateryna Koidan A Detailed Guide to SQL ORDER BY It’s often necessary to display the output of SQL query in specific order rather than arbitrarily. In this article, I’ll explain the many ways you can do it with the SQL ORDER BY clause. To sort records in SQL, you’ll need to use the ORDER BY clause. In this article, I’ll explain in detail how to use ORDER BY to sort output by one or more columns, in ascending (A-Z) or descending (Z-A) order, and by using existing column(s) or using column(s) calculated by an aggregate function. Read more 5 May 2021 Kateryna Koidan A Guide to SQL Common Table Expressions Common table expressions are a relatively new SQL feature that is sometimes overlooked by experienced practitioners working with relational databases. Don’t be one of them! Learn how to use SQL CTEs and join the many data analysts enjoying the benefits of this great tool. Common table expressions (CTEs), also known as WITH clauses, are used to create named subqueries that can be referenced in the main query. CTEs are not saved for future use and can be referenced only within the query where they are defined. Read more 9 Apr 2021 Kateryna Koidan 7 SQL JOIN Examples With Detailed Explanations Do you need to join several tables to get the necessary result set? The SQL JOIN is a basic yet important tool used by data analysts working with relational databases. And I understand it can be difficult to choose from the zillions of introductory guides to joins. In this article, I will focus on real-world examples with detailed explanations. Introduction to JOIN With relational databases, the information you want is often stored in several tables. Read more 2 Apr 2021 Kateryna Koidan What Is the RANK() Function in SQL? Who are your top 10 customers? Who are the top-performing employees in each department? To answer questions like these, you’ll need to rank the output of your SQL query. Let’s see how the RANK() function assists with ranking results in SQL. There are many use cases in which you might need to rank rows in SQL. You may want to rank customers based on the sales volume, students based on their exam results, company assets based on their present value, departments based on the number of employees, or users based on their date of registration. Read more 9 Mar 2021 Kateryna Koidan Why the SQL WITH Clause Is Awesome If you’re not using WITH clauses yet, it’s definitely time to start! SQL WITH clauses, or common table expressions, help improve the structure of SQL queries by making them more readable. That’s already a lot, but WITH clauses have many more benefits. Let’s see together! The WITH clause was introduced in SQL:1999 to define views that are only valid for the query they belong to. Also known as common table expressions (CTEs), WITH clauses allow us to improve the structure of an SQL statement without polluting the database namespace. Read more «« « 1 2 3 4 5 » »»