25 Nov 2020 Tihomir Babic How to Find All Employees Under Each Manager in SQL 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 29 Oct 2020 Tihomir Babic What is COUNT(*), COUNT(1), COUNT(column), and COUNT(DISTINCT) in SQL? 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 28 Oct 2020 Tihomir Babic What are SQL CTE Best Practices? 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 17 Sep 2020 Tihomir Babic How to Use 2 CTEs in a Single SQL Query 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 25 Aug 2020 Tihomir Babic How to Calculate the Length of a Series with SQL 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 16 Jul 2020 Tihomir Babic When Should I Use a Common Table Expression (CTE)? Interested in hearing more about common table expressions or CTEs? Would you like to know when CTEs are useful? Read on—we’ll discuss in this article. If you’ve heard of common table expressions, you’ve probably wondered what they do. Even if you have not, it’s good that you’re here! CTEs can be very useful, especially if you have already mastered the basics of SQL, such as selecting, ordering, filtering data, and joining tables. Read more 16 Jun 2020 Tihomir Babic How to Practice SQL Window Functions at Home Are you looking for a way to maintain your knowledge of SQL window functions? What’s the best way to practice them at home? Here are some suggestions. Learning something new feels great, but it’s also arguably the easiest part of gaining knowledge. You’ve probably experienced that yourself. You struggle with learning an idea, and then you finally get it! There’s the feeling you’ve learned something. And then, very soon, you practically have to start all over again with the very same concepts. Read more 27 May 2020 Tihomir Babic 5 Advanced SQL Constructions Every Data Analyst Should Learn Does your job involve data analysis? Here are five examples of how advanced SQL can help you in your daily work. I’m a data analyst and I have to say – data analysts can be quite strange. Other people are usually afraid of immense amounts of data; we enjoy it. The deeper we get into data, the happier we are. An important tool for getting into data (and thus being a happier data analyst) is SQL. Read more 13 May 2020 Tihomir Babic 11 Advanced SQL Interview Questions (and Answers) Do you want to move to a job that uses SQL? Are you unsure about what to expect during the job interview or how to benchmark your knowledge? This article will give you a good idea of where you stand. If you feel stuck in your job, you’re not the only one. The modern division of work pushes people to perform very specific tasks, expecting them not to look at what's on the other side. Read more 22 Apr 2020 Tihomir Babic When Do I Use SQL Window Functions? Have you heard one of your colleagues bragging about using SQL window functions? Do you know basic SQL but not much, or anything, about window functions? If you want to learn about window functions and how to use them in a business context, you’re in the right place! This happens often. You reach a certain level of knowledge, and you feel like the king (or queen) of the world. Read more «« « 1 2 3 … 7 8 9 » »»