27 Apr 2023 Tihomir Babic How to Use the SQL RANK OVER (PARTITION BY) Ranking data in SQL is a breeze if you know how to use RANK() to rank over a partition. This article shows you how to do it, as well as how RANK() differs from DENSE_RANK() and ROW_NUMBER(). If you work with SQL in a professional setting, you have had to rank data at least once. Think of ranking months/years/quarters by revenue or costs, best-selling products, most viewed posts or streamed songs, employees by salary, most profitable branches, you name it. Read more 18 Apr 2023 Tihomir Babic 10 Beginner SQL Practice Exercises With Solutions Solve these ten SQL practice problems and test where you stand with your SQL knowledge! Practice is the best way to learn SQL. In this article we show you ten SQL practice exercises for beginners, where you can test your basic SQL knowledge. Use them as a practice or a way to learn new SQL concepts. For more theoretical background and (even more!) exercises, there’s our interactive SQL Basics course. Read more 28 Mar 2023 Tihomir Babic How to Solve the “must appear in the GROUP BY clause or be used in an aggregate function” Error in PostgreSQL Learn what causes one of the most common PostgreSQL GROUP BY errors and how you can fix it! As a PostgreSQL user, you surely encounter many error messages when writing an SQL code. Sometimes they are quite unclear, but you won’t need an interpreter for this one: “must appear in the GROUP BY clause or be used in an aggregate function”. This error message mentions GROUP BY and aggregate functions. Read more 16 Mar 2023 Tihomir Babic The SQL COUNT() Function: A Detailed Guide This guide will give you a detailed explanation (with examples) of all the typical uses of the COUNT() function. Exercises included! The COUNT() function in SQL is one of the most commonly used aggregate functions. Aggregate functions in SQL are used to calculate statistics for a group of rows: counting the number of rows in each group, computing the sum of values in a group, finding the minimum or maximum value in a group, and so on. Read more 23 Feb 2023 Tihomir Babic Top 27 Advanced SQL Interview Questions with Answers Where can an SQL professional find a comprehensive guide to advanced SQL interview questions? The shortest answer is: here! We selected the 27 most important SQL questions and answered them for you. Preparing for an SQL interview is not easy, especially if your job requires the knowledge of advanced SQL. This article contains the 27 most commonly asked advanced SQL interview questions and provides detailed answers and resources for further reading. Read more 21 Feb 2023 Tihomir Babic 6 Useful Examples of CTEs in SQL Server How can you use CTEs in SQL Server in your everyday professional life as a data pro? We’ll answer this question by giving you six examples. CTE is short for Common Table Expression. This is a relatively new feature in SQL Server that was made available with SQL Server 2005. A CTE is a temporary named result. This result is available only for the query that runs it. It isn’t stored, so it doesn't take up disk space. Read more 19 Jan 2023 Tihomir Babic What Is a CTE in SQL Server? What is a CTE, and how do you write a CTE in SQL Server? Join us on a journey where we’ll see all the typical usage of a CTE in SQL Server. CTEs (or Common Table Expressions) are an SQL feature used for defining a temporary named result. You can think of it as a temporary table whose output is available only when the main query is run. This is practical because the CTEs result isn’t stored anywhere but can always be referenced inside the query like any other table. Read more 12 Jan 2023 Tihomir Babic How to Practice SQL Window Functions Online Learn and practice SQL window functions from the comfort of your home! Here’s how to do it. The last few years have shown that working from home has many benefits over the daily commute. No wonder people are reluctant to go back to the office! They have much more time while doing the same work. What do you do with the extra time? Whatever you want. It’s your time! Read more 13 Dec 2022 Tihomir Babic 5 Practical Examples of SQL’s WITH Clause These five practical use cases will make you want to use the SQL WITH clause daily. The WITH clause can help you write readable SQL queries and break complex calculations into logical steps. It was added to SQL to simplify complicated long queries. In this article, we’ll show you 5 practical examples of the WITH clause and explain how using it makes SQL queries more readable. The WITH clause is also called a Common Table Expression (CTE). Read more 10 Nov 2022 Tihomir Babic How to Use GROUP BY in SQL In this article, we’ll give you a step-by-step guide on using GROUP BY in SQL. Uncover the nuances of the GROUP BY clause and learn different ways of using it. GROUP BY is one of the most-used clauses in SQL. It moves you from simply selecting data from the database to grouping rows with the same column values into one group. When used with SQL’s aggregate functions, you can use GROUP BY to compute metrics like counting the number of instances or finding the total, average, minimum, or maximum value. Read more «« « 1 2 3 4 … 9 » »»