25 Jun 2024 Ignacio L. Bisso The SQL EXISTS Operator Using the SQL EXISTS clause allows us to create complex queries in a simple way. Learn the pros and cons of the EXISTS operator in this article. In SQL, the EXISTS operator helps us create logical conditions in our queries. Essentially, it checks if there are any rows in a subquery. We’ll show you EXISTS syntax, provide some usage examples, and then give you several exercises to practice on. Read more 27 Feb 2024 Ignacio L. Bisso 6 Examples of NTILE() Function in SQL The SQL NTILE() function can greatly simplify your data analysis and reporting. Follow these six examples to learn what it is and when to use it. Window functions are very useful, providing great expressive power to SQL. In this article, we discuss the NTILE() function, which allows us to divide a set of records into subsets of approximately equal size. This function is widely used in financial or economic calculations. Read more 18 Dec 2023 Ignacio L. Bisso Can You Use Multiple WITH Statements in SQL? A comprehensive guide to multiple WITH statements in SQL, perfect for beginners and experts alike. The SQL WITH clause allows you to define a CTE (common table expression). A CTE is like a table that is populated during query execution. You can use multiple WITH statements in one SQL query to define multiple CTEs. In this article, we will explain how to define multiple CTEs in a single query. Read more 16 Nov 2023 Ignacio L. Bisso 10 GROUP BY SQL Practice Exercises with Solutions Need to practice your SQL skills? These 10 GROUP BY practice exercises – with explanations and solutions – are a great start! GROUP BY is a powerful SQL clause that allows you to create groups of records and then calculate summary metrics (such as averages) for those groups. However, GROUP BY is often challenging for SQL learners to master. Yet, practicing GROUP BY is very important if you’re planning on using SQL. Read more 28 Sep 2023 Ignacio L. Bisso How to Use ROW_NUMBER OVER() in SQL to Rank Data Sometimes you need to know the position of rows in a result set. Learn how using ROW_NUMBER and OVER in SQL can make it happen! Have you ever needed to add a sequential number to the records returned by an SQL query? Or perhaps you need to create a ‘top n’ report based on a specific ranking. In any of these cases, you need to calculate the position of the row in the ranking. Read more 7 Sep 2023 Ignacio L. Bisso COUNT OVER PARTITION BY: An Explanation with 3 Examples In SQL, combining the COUNT() function with the OVER() clause and PARTITION BY opens the door to a totally different way to count rows. In this article, you’ll learn how to do several COUNTs in a single query and calculate expressions based on the result of the COUNT function. In this article, we will cover how you can use the COUNT() function combined with the clauses OVER() and PARTITION BY. Read more 1 Aug 2023 Ignacio L. Bisso CTE in T-SQL: A Beginner’s Guide with 7 Examples A common table expression (CTE) is a powerful T-SQL feature that simplifies query creation in SQL Server. CTEs work as virtual tables (with records and columns) that are created on the fly during the execution of a query. They are consumed by the query and destroyed after the query executes. In some cases – like when the query expects data in a specific format and the source tables have the data in another format – a CTE can act as a bridge to transform the data in the source tables to the format expected by the query. Read more 28 Feb 2023 Ignacio L. Bisso 25 Advanced SQL Query Examples One of the best ways to learn advanced SQL is by studying example queries. In this article, we'll show 25 examples of advanced SQL queries from medium to high complexity. You can use them to refresh your knowledge of advanced SQL or to review before a SQL interview. Many of the examples in this article will be based on the following employee table. Only a few examples will be based on other tables; in these cases, the tables will be explained along with the example. Read more 29 Dec 2022 Ignacio L. Bisso How to Practice SQL Subqueries Have you ever wondered what separates beginners from advanced SQL users? It includes things like, for example, subqueries. In this article, I explain their importance and why you need to practice SQL subqueries to become an expert. What Is an SQL Subquery? SQL is an easy-to-learn language. However, there are certain complex features and techniques of the language that require practice. One of these features is the subquery, which adds great expressive power to the language and your projects. Read more 29 Nov 2022 Ignacio L. Bisso How to Choose Data Types for SQL Table Columns Databases store data values of various kinds. For example, you may store the name of a product as a text string, the price of a product as a number, or the date a product is sold as a date value. These values – the product name, the price, and the sale date – are stored as different data types. In this article, we explain several SQL data types with real examples. Read more «« « 1 2 3 … 6 » »»