Articles Cookbook

Tag: Advanced Sql

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.

Learn Advanced SQL with LearnSQL.com

In this article, we will propose a learning path that will cover advanced SQL topics. If you already know the basics of SQL, you probably have figured out that most online and offline SQL tutorials and courses usually cover the basic and intermediate concepts: SELECT, FROM, WHERE, ORDER BY, GROUP BY, and joining tables. Even university database courses typically don’t cover more advanced  SQL topics. While this is enough SQL for most everyday tasks, there are some relatively new features that have been added to SQL in the last 20 years: window functions, recursive queries, and GROUP BY extensions (ROLLUP, CUBE, GROUPING SET).

Tag: Aggregate Functions

GROUP BY and Aggregate Functions: A Complete Overview

SQL’s GROUP BY and aggregate functions are essential in data aggregation – and for analyzing data and creating reports. Let’s explore them together!   In SQL, GROUP BY and aggregate functions are one of the language’s most popular features. Data aggregation is critical for data analysis and reporting; to make sense of all the data in a dataset, it often needs to be aggregated. But what is data aggregation? Put simply, it’s when you group data based on common values and perform a calculation for each data group.

SQL Aggregate Functions Cheat Sheet

A quick reference guide to using SQL aggregate functions. This SQL Aggregate Functions Cheat Sheet is designed to be your companion whenever you’re using SQL for data analysis. Aggregating data is essential for any meaningful data analysis. SQL provides a set of functions that allow you to include totals, averages, and counts in your reports and to extract the minimum and maximum value of any column of data.

SQL Aggregate Functions: A Comprehensive Guide for Beginners

Are you curious about SQL aggregate functions and how they apply to real-world scenarios? In this article, we'll explore SQL aggregate functions, showcase real-world examples, and offer valuable insights on how to master them. Data aggregation is the process of taking several rows of data and condensing them into a single result or summary. When dealing with large datasets, this is invaluable because it allows you to extract relevant insights without having to scrutinize each individual data point.

How to Use Aggregate Functions in WHERE Clause

Filtering data according to the result of an aggregate function is a common data analysis task. So how do you use aggregates in the  WHERE clause? We’ll dedicate this whole article to answering that question.   Combining aggregate functions and filtering based on their results is often used in data analysis – e.g. showing branches with total sales above X,  countries where the number of posts is lower than Y, students with an average score below Z, and so on.

How to Combine Two Aggregate Functions in SQL

Having trouble using two aggregate functions in one query? This article will show you how to do it the right way – actually, the two right ways. In data analysis and reporting, we often need to count the number of records or sum them up and then calculate the average of this count or sum. Translated to SQL logic, this is the aggregation of aggregated data, or multi-level aggregation. For aggregation purposes, there are the SQL aggregate functions.

What Are Aggregate Functions in SQL, and How Do I Use Them?

Data is your source of knowledge. And thanks to SQL aggregate functions, you can extract the precise knowledge you need from your data efficiently. Read along to find out more. The core SQL aggregate functions are the following: COUNT(column_name | *) returns the number of rows in a table. SUM(column_name) returns the sum of the values of a numeric column. AVG(column_name) returns the average value of a numeric column.

Aggregate Functions vs Window Functions: A Comparison

If you aren’t familiar with SQL’s window functions, you may wonder how they differ from aggregate functions. When should you use window functions? In this article, we’ll review window functions and aggregate functions, examine their similarities and differences, and see which one to choose depending on what you need to do. After you’ve tackled basic SQL, you’ll probably want to get into some of its more advanced functions. That’s great; these functions make reporting and analysis easier.

Common SQL Window Functions: Positional Functions

Positional SQL window functions deal with data's location in the set. In this post, we explain LEAD, LAG, and other positional functions. SQL window functions allow us to aggregate data while still using individual row values. We've already dealt with ranking functions and the use of partitions. In this post, we'll examine positional window functions, which are extremely helpful in reporting and summarizing data. Specifically, we'll look at LAG, LEAD, FIRST_VALUE and LAST_VALUE.

Statistics in SQL: Measuring Spread of Distribution

Besides knowing the centers of a distribution in your data, you need to know how varied the observations are. In this article, we’ll explain how to find the spread of a distribution in SQL. Are you dealing with a very uniform or a very spread population? To really understand what the numbers are saying, you must know the answer to this question. In the second part of this series, we discussed how to calculate centers of distribution.

An Introduction to Using SQL Aggregate Functions with JOINs

Previously, we've discussed the use of SQL aggregate functions with the GROUP BY statement. Regular readers of the our blog will also remember our recent tutorial about JOINs. If you're a bit rusty on either subject, I encourage you to review them before continuing this article. That's because we will dig further into aggregate functions by pairing them with JOINs. This duo unleashes the full possibilities of SQL aggregate functions and allows us to perform computations on multiple tables in a single query.

NULL Values and the GROUP BY Clause

We've already covered how to use the GROUP BY clause and some aggregation functions like SUM(), AVG(), MAX(), MIN(), COUNT(). In this article, we will explain how the GROUP BY clause works when NULL values are involved. We will also explain about using NULLs with the ORDER BY clause. The best way to master GROUP BY and NULL in SQL is through practice. I recommend the SQL Practice track at LearnSQL.

Tag: Alias

How to Use Aliases with SQL JOINs

SQL aliases are custom names that you can give to the columns and tables you include in your queries. Aliases are very useful, as they can greatly improve the readability and maintainability of your query. We’ll be taking a closer look at using SQL aliases with JOIN and why you might need to do so. The best way to master aliases in SQL is practice. I recommend our interactive SQL Practice Set course.

Tag: Avg

The SQL AVG() Function Explained With Examples

We explain the SQL AVG() function with practical examples, covering how and where you can and cannot use it. The average is probably one of the most widely used metrics to describe some characteristics of a group. It is so versatile and useful that it can describe something about almost anything. If you like sports, you see things like average runs per game in baseball, average assists per game or per season in basketball, and so on.

The SQL Coalesce Function: Handling Null Values

You may already know how to return null values in SQL. Now, we’re going to learn how to do the opposite. Though the SQL COALESCE function may seem complex, it’s actually very straightforward and useful. Let’s look at several examples of how the SQL COALESCE function can be used to work with NULL values in SQL. The Need for Coalesce in SQL Before we dive into the SQL COALESCE function in detail, you should understand how NULL values behave in expressions.

SQL Date and Interval Arithmetic: Employee Lateness

Computing Tardiness: Date, Time, and Interval SQL Arithmetic In this article, we’re going to discuss some interesting operations we can perform with date-related data types in SQL. The SQL standard, which most relational databases comply with these days, specifies the date-related data types that must be present in relational databases. The most important of such data types are date, time, timestamp, and interval. Here’s a brief rundown of the differences between these data types:

Tag: B2b Offer

LearnSQL.com For Your Business

Are you thinking about SQL training for your employees? See how much you have to gain by choosing LearnSQL.com and how we can help you grow your business. .pre-header { color: #006DFF; text-transform: uppercase; letter-spacing: 2px; font-size: 14px; font-weight: 400; line-height: 16px; margin-top: 60px; } We live in a time when the ability to process data is crucial. Data is a key resource, the use of which can give you an edge in the market.

Tag: Behind the Scenes

4th Anniversary of LearnSQL.com

Time runs so fast. This week, we celebrate the 4th anniversary of LearnSQL.com. We have come a long way together and we promise to get even better in the upcoming year! Thank you for being with us. 1459 days have passed since February 23, 2020, when we launched the LearnSQL.com platform. That's 35,016 hours, or 2,100,960 minutes, if you prefer. It's been a long time, but it feels like yesterday that we started out together.

How to Set Up a Corporate SQL Training Program

Are you looking to set up a business or corporate SQL training for your company's employees? In this article, we’ll discuss how to build an efficient SQL training program and why the LearnSQL.com platform is the choice of leading tech companies. If you are responsible for employees’ professional development – especially in a data-driven company – you know that SQL is essential for anyone who works with data. This programming language can enhance the performance of data and business analysts (for whom SQL is often a primary tool) as well as marketers, salespeople, HR specialists, auditors, and many more.

Fall 2021 Track of the Season: SQL from A to Z

The ability to analyze data is one of the most sought-after skills in job applicants. Why? Because all organizations want to take advantage of the power of data. And one of the basic tools for that is SQL! See why we have chosen the SQL A to Z track as our track of the season. This fall, take your analytical skills to the next level! Let's start with the basics.

SQL Track of the Season: SQL Fundamentals in PostgreSQL

Are you ready for a new challenge this spring? Check out our SQL Track of the Season: SQL Fundamentals in PostgreSQL! In this article, we’ll answer common questions about this track. It’s getting warmer. The flowers are slowly beginning to bloom. This can mean only one thing – spring is here. The world is coming to life after its wintertime lethargy. This is a great time for new challenges. Do you want to add something to your skillset?

Winter 2021 Track of the Season: Creating Database Structure

New year, new challenges, and ... a new SQL Track of the Season! Start 2021 by learning SQL and data engineering. In this article, we answer frequently asked questions about our Creating Database Structure track. Maybe you haven't noticed yet that there’s an order to many LearnSQL.com courses; you can learn SQL by doing them in the right order. We call this option our ‘SQL tracks’. These are logically structured and well-thought-out learning paths that will help you take the next steps towards becoming an SQL expert.

SQL Means Business - The Way of an Engineer

Have you been wondering why some companies fail and others achieve success? It's not a matter of luck but of the right people. Łukasz Kubicki at Vertabelo deals with business and product development. I asked him how he started his adventure with programming, how an engineer got into business, and if he liked playing computer games. Here's what he said. If you were to write one sentence about yourself, what would it be?

Did You Know LearnSQL.com Has Free SQL Courses?

Who doesn't like getting something for free? Each month, we give LearnSQL.com users a bit of help in their learning journey – a free, fully interactive SQL course. Since April, we have been giving our users the opportunity to learn SQL for free. Each month, we choose one of our SQL courses and give you full access to it for that month – completely free of charge! Cool, right?

Creating SQL Courses: Behind the Scenes at LearnSQL.com

Take a peek behind the scenes and learn our secret for creating great SQL courses! Have you ever wondered how LearnSQL.com courses are created? Are we looking at a lot of hard work or just a bit of magic? Or maybe both? Here’s a hint: we rely on proven methods to create user-friendly online courses. But it’s not easy! Read on to see the 8 steps we take when creating a new SQL course.

Fall 2020 Track of the Season: SQL from A to Z

During Fall 2020, our main SQL track, SQL from A to Z, will be in the spotlight. In this article, we answer the most frequently asked questions about this track. At LearnSQL.com, our SQL courses are organized into tracks. A track is a sequence of courses designed to help you achieve a specific learning goal. The courses in the track are in a recommended order that progresses from the easiest to the most challenging.

A Mathematician in the World of SQL

She has a PhD in Mathematics and over 10 years’ experience teaching mathematics and computer science at the University of Warsaw. She knows SQL better than just about anyone I’ve met. Let’s get to know Agnieszka Kozubek-Krycuń, Vertabelo’s Chief Content Officer at Vertabelo. Let's go back in time. How did your adventure with math start? I’ve always enjoyed abstract concepts and problem solving. I was fascinated by variables when we learned to solve simple equations like x+2=5 in primary school.

You Want to Learn SQL? You've Come to the Right Place!

It is difficult to list all the benefits of learning SQL. You will work faster and more efficiently with a database, you will no longer be dependent on the IT department, and you will be able to analyze the data yourself and draw appropriate conclusions, among others. Add reporting to this, and you will get a very wide range of cool and useful skills. Maybe you want to change jobs or get a promotion?

Why Take the “SQL Basics” Course at LearnSQL.com

LearnSQL.com’s interactive “SQL Basics” course teaches the foundations of SQL. Discover why we built this online course, our philosophy behind it, and what it contains! What Is SQL, and Why Should You Learn It? SQL is a language used to talk to databases, computer programs that hold data and can process it efficiently. SQL can select data from a database and perform various computations on the data, be they simple or complex.

The Man Behind LearnSQL.com

If it wasn't for this guy, LearnSQL.com would never have been created. He manages the entire company, makes strategic decisions – and talks little about himself. Who is the man behind LearnSQL.com? Meet Vertabelo CEO Jarosław Błąd. SELECT interests, early_career, advice FROM Jarek AS the_man_behind_learnsql.com WHERE answer IS NOT Null AND success IS True; If you were to write one sentence about yourself, what would it be? I think I would say that I am an ordinary, simple guy who really likes what he does.

SQL Cookbook with Recipes for Success

The internet holds a lot of information and can provide solutions to various problems. SQL users, both beginners and advanced, often turn to the internet for help with SQL queries. This article will help you find the right SQL queries to solve your problems. Learn what the SQL Cookbook is and why you should use it. You will also find a list of the most important recipes, from which you will prepare a great SQL dish with the taste of success.

Tag: Bi

How to Get More from Your BI Tools with SQL

Are you frustrated with the limitations of your business analytics tool? Do you wonder if there are other features you could tap into? Would you like to know how SQL compliments your work with Power BI and Tableau? Read this article to learn more! If you are a data analyst or if data analysis is part of your everyday job, Business Intelligence (BI) tools are crucial for your work. You also know that most databases run SQL queries in the background of such tools.

Tag: Bigquery

An Overview of SQL Text Functions in Google BigQuery

Data analysts and Google BigQuery go hand in hand. Google's cloud data warehouse presents you with plenty of opportunities for using standard SQL text functions you can't avoid in your day-to-day work as a data analyst. BigQuery uses Google Standard SQL, an ANSI-compliant SQL dialect. This means you can use standard SQL text functions in BigQuery without needing to learn a variant of a given function. The Standard SQL Functions course is an excellent resource for learning those functions.

Tag: Book

Best SQL Books for Data Analysis

In the world of data analysis, SQL is a powerful tool. It's a language that helps professionals find, organize, and analyze the data stored in databases. If you're looking to learn this important skill, you've come to the right place. This article will guide you through the best SQL books for data analysis, whether you're just starting out or already have some experience. SQL (Structured Query Language) is a standard language used for working with databases.

The Best Database Books You Should Read Now

So, you're interested in databases and looking for some database book recommendations. In this article, we’ll take a look at our top database book recommendations to feed your brain. In essence, databases are like digital filing cabinets. They have the ability to organize, store, and retrieve data. Large amounts of data are stored, managed, and made easily accessible by using databases. Additionally, databases make it possible for data to be organized into tables, which makes searching and sorting easier.

SQL Books for Beginners

How can you learn SQL more efficiently? Besides a good online course, find an interesting book to enrich your knowledge. Here are the best SQL books for beginners. SQL, or Structured Query Language, is a very powerful tool to work with many types of data. If you are interested in learning SQL you probably know how useful it is, and how widely it is needed. To learn SQL successfully, a solid online course for beginners like our SQL Basics is a great start.

A Chat with Anthony DeBarros, Author of Practical SQL

Some make model ships, others collect stamps. I read SQL books. I've read a lot of them, but only a very few deserve to be called really good. Some of them were included in my Best SQL Books list. The good news is that one of them just got a new release. It was great, even better than the previous edition! Moreover, I was able to talk to its author, Anthony DeBarros.

Read These 5 Data Analysis Books to Jump-Start Your Career

Do you want to pivot into a data analyst role, but you are unsure where to start? Do you do analytics in your job and would like to learn more about the big picture of data? Are you looking for a great data analysis book to read? In this article, you will find our selection of the best books on data analysis! If you are a business professional thinking about picking up data analytics skills, you may be wondering how you should start.

Our 6 Favorite SQL Books

So you want to learn SQL and query databases? Great! Check out these six SQL books for an in-depth look at the language and you’ll be writing queries in no time! You take SQL courses, participate in internet discussions and forums, watch tutorials on YouTube... What else can you do to develop your skills? Sometimes it’s good to reach for old-fashioned sources of knowledge: SQL books. Which book(s) should you choose?

Book Review: “Learn SQL the Hard Way” by Zed A. Shaw

“Learn SQL the Hard Way” by Zed A. Shaw is a great ebook for those who want to learn SQL essentials. At $19.99 USD, it may seem a bit expensive for an ebook, but you’re getting a DRM-free PDF, plus a whole bunch of explanatory videos and additional files. Who should read “Learn SQL the Hard Way”? Anyone interested in SQL basics – modifying databases or selecting information. Make no mistake about it: this book focuses heavily on the practical side of database language.

5 Books That Will Grow Your SQL Skills

Updated on: April 18, 2024 Looking to take your database skills up a notch? I've spent some time digging into various resources, and I want to share five advanced SQL books that really stood out. These texts are not just about learning the basics: they're about mastering the intricacies of SQL and truly enhancing your database management prowess. Whether you're troubleshooting complex queries or optimizing performance, these books provide insights that are both practical and transformative.

Tag: Books

The Best Books for Data Engineers

Are you tired of staring at a computer all day? Maybe it’s time to read a book. Take a moment to check out our list of recommended books for data engineers. They will help you deepen your knowledge about databases. Last year, we shared a list of the best books to learn SQL. This time, I want to introduce five books for data engineers. They are worth reading and will help you learn more about databases.

Tag: Books to Learn Sql

The Best SQL Books for 2024

In 2024, finding the right resources to learn SQL is more important than ever. But with so many options out there, how do you choose the best one? In this guide, I will share some top SQL books to help you learn and master SQL this year. SQL, or Structured Query Language, is a tool that helps you work with data stored in databases; it lets you find and change information quickly and easily.

Tag: Calculating

Statistics in SQL: Centers of Distribution

My previous article explained how to calculate frequencies using T-SQL queries. Frequencies are used to analyze the distribution of discrete variables. Today, we’ll continue learning about statistics and SQL. In particular, we’ll focus on calculating centers of distribution. We’ll learn e.g. how to calculate the SQL median, what functions to use to calculate the SQL mode, and how to calculate various types of mean in SQL (geometric mean, harmonic mean and, of course, arithmetic mean).

Statistics in SQL: Calculating Frequencies & Histograms

Database and Business Intelligence (BI) developers create huge numbers of reports on a daily basis, and data analyses are an integral part of them. If you wonder whether you can perform statistical analysis in SQL, the answer is ‘yes’. Read my article to learn how to do this! Statistics are very useful as an initial stage of a more in-depth analysis, i.e. for data overview and data quality assessment. However, SQL statistical analysis possibilities are somewhat limited as there are not many statistical functions in SQL Server.

Tag: Career in Data Science

How to Become a Big Data Engineer

What is a Big Data engineer, and how is their skill set different from a data engineer? In this article, we explore the tools and platforms you’ll need to master as a Big Data engineer. To move from being a regular data engineer to a Big Data engineer, you need to acquire several new skills and learn to use several new tools. The good news is that Big Data still lets you use your good old SQL skills to manipulate and get information from data repositories.

Why Use SQL Over Excel

SQL is replacing Excel in many fields, and data analysis is certainly one of them. If you are still using Excel as a data analyst, you are missing something very valuable. SQL can make your life easier, as it's more efficient and faster than Excel. So, how and from where can you learn SQL? How Can SQL Help Data Analyst? You can use SQL to help you with the following work:

Career Change: From Accountant to Database Designer

How do career changes and life choices impact our future? Can we change the path that's been set for us? And if so, where do we begin? I wouldn't blame you if you thought this article is about change. In a sense, it is—it's in the title, after all. But for me, this article is more about what remains constant. If somebody were to ask me what hasn't changed for me since my childhood, I would know the answer immediately: curiosity.

Complete SQL Practice for Interviews

Congratulations! Your SQL skills were strong enough to get you that job interview! Now, if you only knew what SQL questions and practical exercises a recruiter might ask you to do… This article is meant as a SQL practice for interviews. I’ll help you prepare for the SQL and database aspects of your job interview. In a previous article, I explained how can you boost your career by learning SQL.

Finding the Perfect SQL Job

So you have some SQL skills and you're looking for a job that will use them. What are your options? SQL is everywhere, and there's a huge demand for people with database management skills. This is especially the case when companies start implementing Big Data solutions and strategies. There's no arguing that SQL is a must-have skill. If you're already proficient, how can you put your expertise to practical use in the job market?

A Day in the Life of a SQL Developer

What is a SQL developer? And what does a SQL developer do? Describing a “typical” day for a SQL developer is not easy. When your daily work is using various technologies to create interesting database-oriented products, very few days are alike! Each day brings a new and intriguing challenge. Nevertheless, I’ll have a go at explaining what everyday things a SQL developer might do. Morning: Arrive at Work What does a SQL developer do after arriving at the office?

Tag: Case

SQL CASE WHEN Explained: 10 Easy Examples for Beginners

The CASE WHEN statement lets us make decisions on our data, categorizing and manipulating records based on specified conditions. Find out how to use CASE WHEN in this article. Imagine you're deciding what to wear for the day. You take out your umbrella if it's raining; if not, you leave it at home. This decision-making procedure is essentially the same as a SQL CASE WHEN statement. In the realm of SQL, the CASE WHEN statement functions much like an if-then-else expression, allowing us to create custom classifications within a query.

How to Use CASE in ORDER BY in SQL

This article will show you how and when to use CASE in an ORDER BY clause. Have you ever used a CASE statement? I’m sure you have, at least in a SELECT statement. But have you ever used it in an ORDER BY clause? No? You will, once I show you how! Don’t worry if you’ve never used a CASE statement. I’ll show and explain it to you with a short example.

How to Use CASE in SQL

Updated on: February 19, 2024 If you need to evaluate multiple conditional statements, the SQL CASE statement will do the job. To effectively harness CASE in SQL, grasping its structure and practical uses is key. I'll guide you through real query examples showcasing the power of this versatile statement. Here’s what you need to know to use CASE like a pro. Why is CASE so important in SQL? If you’re analyzing or manipulating data, you’ll often want to define rules based on certain conditions, e.

Using CASE with Data Modifying Statements

What happens when you combine CASE with SQL's data modifying statements? Find out in this article. The CASE expression is a very useful part of SQL and one that you'll employ frequently. We've already covered what the CASE expression does, how to format it, and how to use it in a SELECT statement in "Using CASE to Add Logic to a SELECT". Another article, "How to Sort Records with the ORDER BY Clause"

Using CASE to Add Logic to a SELECT

As you write an SQL query, you may need to get values from multiple columns and change values from one form to another. The simple way to achieve this goal is to add a CASE expression to your SELECT statement. In this article, we'll introduce you to the syntax, formats, and uses of the CASE expression. The CASE expression is a conditional expression: it evaluates data and returns a result.

Tag: Case When

How to Use CASE WHEN in GROUP BY

Learn how you can combine SQL CASE WHEN and GROUP BY to create custom categories in your SQL queries. Raw data, by its very nature, is not always human readable. Many times, the data you’re querying is in its most unformatted form. Examples of this include codes for different business departments or product SKUs that represent specific products. To the naked eye, these codes mean nothing, so pulling them into a report is not helpful for the person reading them.

What Is CASE in SQL?

SQL CASE is a very useful expression that provides if-else logic to your SQL queries. It’s a slightly more advanced topic, but you’ll need it when preparing reports – it will deliver massive value to your personal and professional projects. The SQL CASE statement is a control flow tool that allows you to add if-else logic to a query. Generally speaking, you can use the CASE statement anywhere that allows a valid expression – e.

Tag: Cheat Sheet

SQL Aggregate Functions Cheat Sheet

A quick reference guide to using SQL aggregate functions. This SQL Aggregate Functions Cheat Sheet is designed to be your companion whenever you’re using SQL for data analysis. Aggregating data is essential for any meaningful data analysis. SQL provides a set of functions that allow you to include totals, averages, and counts in your reports and to extract the minimum and maximum value of any column of data.

PostgreSQL Cheat Sheet

Here's your ultimate PostgreSQL cheat sheet! Whether you're a newbie or an experienced pro in need of a quick reference, this cheat sheet has got you covered. This PostgreSQL Cheat Sheet summarizes the key PostgreSQL commands and features you'll use often. It covers everything from how to connect to a PostgreSQL server and manage database contents, to the basic syntax for table creation and modification. It also breaks down the syntax for SELECT, INSERT, UPDATE, DELETE commands, and shows how to use different PostgreSQL functions, including text functions, numeric functions, NULL functions, and date and time functions.

SQL Server Cheat Sheet

Welcome to the SQL Server Cheat Sheet! Whether you're just starting out with SQL Server or you're a seasoned developer looking for a quick reference, this guide is tailored for you. This cheat sheet is a comprehensive guide to SQL Server, offering a quick reference to its essential commands. It covers the basics of creating and displaying databases and tables, the commands to modify tables, and the fundamental syntax for T-SQL commands such as SELECT, INSERT, UPDATE, and DELETE.

SQL for Data Analysis Cheat Sheet

Welcome to our SQL for Data Analysis Cheat Sheet — a must-have resource for anyone looking to harness the power of SQL in the realm of data analysis. Whether you're a data enthusiast, a business analyst, or a seasoned data professional, this cheat sheet is designed to empower you to extract valuable insights from your datasets. Inside, you'll find a carefully curated collection of SQL commands and tips that will elevate your data analysis game.

MySQL Cheat Sheet

Welcome to the MySQL cheat sheet! Whether you're just starting out with MySQL or you're a seasoned professional looking for a quick reference, this guide is tailor-made for you. This MySQL Cheat Sheet provides a concise and handy reference to the most commonly used MySQL commands and functionalities. It spans a range of topics, from connecting to a MySQL server and managing database contents, to the basic syntax for table creation and modification.

Introducing Our New Ultimate SQL Cheat Sheet!

Do you ever find yourself writing an SQL query and forgetting the syntax of some function? That sometimes happens to me too. Fortunately, LearnSQL.com has prepared this awesome Ultimate SQL Cheat Sheet you can always have on hand. Print it or save it to your browser's favorites and make your data querying more efficient! If you are looking for an SQL Cheat Sheet, it is safe to assume that you already know what SQL is.

Standard SQL Functions Cheat Sheet

Welcome to the ultimate resource for mastering SQL functions - the Standard SQL Functions Cheat Sheet. It's designed to be a quick yet comprehensive reference guide for both beginners and experts. Download yours and start querying with ease. Whether you are a beginner stepping into the world of SQL or a seasoned professional looking to brush up on your skills, our Standard SQL Functions Cheat Sheet is designed to be your go-to guide for SQL functions.

SQL Basics Cheat Sheet

Download this 2-page SQL Basics Cheat Sheet in PDF or PNG format, print it out, and stick to your desk. The SQL Basics Cheat Sheet provides you with the syntax of all basics clauses, shows you how to write different conditions, and has examples. You can download this cheat sheet as follows: Download 2-page SQL Basics Cheat Sheet in PDF format (A4) Download 2-page SQL Basics Cheat Sheet in PDF format (Letter) Download 1-page SQL Basics Cheat Sheet in PDF format (A3) Download 1-page SQL Basics Cheat Sheet in PDF format (Ledger) Download SQL Basics Cheat Sheet in mobile-friendly PDF You may also read the contents here:

SQL JOIN Cheat Sheet

Ready to master SQL JOINs? Get your downloadable cheat sheet now! Your shortcut to becoming an SQL JOINs expert is one click away. Dive deep into the world of SQL JOINs with our detailed SQL JOIN Cheat Sheet, a must-have resource for data enthusiasts at every level. Whether you are just starting out or looking to sharpen your skills, this guide is tailored to provide you with the quick reference needed to use SQL JOINs efficiently.

SQL Window Functions Cheat Sheet

Unlock the full potential of SQL with our comprehensive Window Functions Cheat Sheet! This indispensable guide is designed to elevate your analytics capabilities and make complex data manipulations effortlessly accessible. Welcome to the ultimate resource for mastering SQL window functions - the SQL Window Functions Cheat Sheet! This invaluable resource provides you with the essential syntax, a comprehensive list of window functions, and real-life examples to enhance your SQL skills and analytics capabilities.

Tag: Coalesce

How to Use the COALESCE() Function in SQL

SQL users are often faced with NULL values in their queries and need to process them properly. The COALESCE() function helps handle NULL values. Read this article to learn how to use COALESCE() in your queries. SQL tables store data in records, and records are composed of fields. There can be situations where we don’t know the value for a specific field. For example, let’s suppose we have a table with data for persons.

Tag: Codds Article

53 Years of Relational Databases

If it weren't for him, there would be no modern databases. It is the 53st anniversary of the publication of his article that changed the rules of the game. Edgar Frank Codd is one of the fathers of SQL, and his name is one of the first to be mentioned in the history of databases. Or maybe even the history of computer development in general? See what we owe to Dr.

Tag: Common Sql Functions

18 Useful Important SQL Functions to Learn ASAP

Updated on: October 30th, 2023 Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike.

Tag: Common Sql Mistakes

Extracting Data From a String: SPLIT_PART in PostgreSQL

Learn how to use split_part in PostgreSQL to extract data from strings. Quite often, we’d like to extract parts of a string when working with text values. A common example is when we have a full name and need to retrieve only the last name. In this article, we’ll examine how to do it using split_part in PostgreSQL, i.e. a string-related function that can be used to extract a substring.

How to Remove Junk Characters in SQL

Unwanted characters in text data can be a bit of a pain, but there’s an easy way to fix them. Scroll down to learn how to remove junk characters in SQL in the easiest way! Sometimes, we’ll find unwanted characters inside our string data because our SQL queries didn’t work as expected. Moreover, these extra characters may sometimes be invisible, which really complicates things. In this article, we’ll examine some string-related SQL functions that can handle unwanted characters—visible or not!

How to Solve Capitalization Data Quality Issues

Misspelled names, typos, and text data quality issues in your database? Power up your queries! Use SQL string functions to address data quality issues related to capitalization. Sometimes, our SQL queries don't work as expected because of data quality issues. In this article, we will examine some string-related SQL functions that can correct data quality issues related to capitalization. We'll be using PostgreSQL in our examples, but similar functions are available in most database engines.

Preventing Common SQL Mistakes

Regardless of the engine you are using (SQL Server, MySQL, Oracle, etc.), you can prevent common errors and simplify the debugging process. This article will discuss some of the common SQL mistakes you’ll face and will help you correct them easily. One of the best ways to prevent the most common SQL mistakes is to keep your queries clear and readable. It’s very easy to forget the ideas behind your code!

Tag: Common Table Expressions

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.

SQL CTE Explained

In this article, you will learn about SQL Common Table Expressions (CTEs). This powerful SQL tool will help you simplify complex queries. Additionally, I will introduce you to the two main types of CTEs and some of their use cases.  CTE Primer The Common Table Expression (CTE) was introduced to standard SQL to simplify long, complex queries (especially joins and subqueries). It is a temporary data set returned by a query that contains data separate from the main query.

How to Draw a Christmas Tree in SQL

You can use SQL to manipulate all kinds of data, from huge analytical queries to brief single-purpose statements. But you can also use SQL just for fun, without any business requirements stifling your creativity. So, get out your jolly hat and prepare to sing O Christmas Tree as we create some quirky art with plain old SQL. Today, we’re going to generate some holiday-themed ASCII art, just for fun. That’s right.

Simplify SQL Code: Recursive Queries in DBMS

Hey SQL users! Are you repeating the same query in every report? Are your queries getting too complicated? Use recursive queries to simplify SQL code! Too many SQL reports can lead to clutter on your desktop and in your head. And is it really necessary to code each of them separately? Ad-hoc queries can share much of the same SQL code with managerial reports and even regulatory reports. Suppose you’ve been writing basic SQL code for a while.

How to Organize SQL Queries with CTEs

Common table expressions (CTEs) allow you to structure and organize SQL queries. Knowing how to organize SQL queries is a necessity when you begin to move deeper into SQL, so if you want to become an SQL master, you need to know CTEs. The SQL CTE has been part of standard SQL for some time now. CTEs – which are also called WITH statements – are available in all major RDBMS.

Long SQL Query vs. Recursive SQL Query

Recursion is one of the central ideas in computer science. We can define it as a method for solving problems where the solution of the problem depends on solving a smaller instance of a problem. If this sounds complicated do not fret, in this article we will learn about recursion in SQL that you can practice and deepen in Vertabelo Academy. Recursion is a way of solving hierarchical problems we find in data with common SQL.

Tag: Concatenation

How to Concatenate Two Columns in SQL – A Detailed Guide

In SQL, concatenation is the operation of joining together strings, or pieces of text information. Learn how to concatenate two columns in SQL with this detailed guide. SQL concatenation is the process of combining two or more character strings, columns, or expressions into a single string. For example, the concatenation of 'Kate', ' ', and 'Smith' gives us 'Kate Smith'. Enhance your SQL skills with our interactive SQL Practice Set!

Tag: Constraints

What Is a NOT NULL Constraint in SQL?

SQL has several ways of dealing with NULLs. In this article, we’ll focus on the NOT NULL constraint and other NULL-related clauses. Understand this and you’ll take an important step in your SQL growth! Before we get straight into the NOT NULL constraint, let’s quickly define what NULLs and constraints are. NULL values are a central concept in SQL databases. The idea behind a NULL value is simple: a NULL value means that we do not have a known value for that field.

Tag: Count

The SQL COUNT() Function: A Detailed Guide

Updated on: April 22, 2024 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.

The SQL Count Function Explained With 7 Examples

One of the most useful aggregate functions in SQL is the COUNT() function. If you are new to SQL and want to learn about the various ways to use the COUNT() function with some practical examples, this article is for you. The COUNT() function is one of the most useful aggregate functions in SQL. Counting the total number of orders by a customer in the last few days, the number of unique visitors who bought a museum ticket, or the number of employees in a department, can all be done using the COUNT() function.

Tag: Course of the Month

SQL Track of the Season: SQL from A to Z in MySQL

Do you feel the spring already? Everything is in full bloom at this time of the year. Why shouldn’t it be the same with your career? You just need to water it with a new skill. Here is the brilliant SQL from A to Z in MySQL track, our Track of the Season. In this article, I answer common questions about this awesome set of online MySQL courses. Why should you care about relational databases at all?

Free SQL Course of the Month – Revenue Trend Analysis in PostgreSQL

Need to understand what your data is saying about your business? In April 2024, our Free SQL Course of the Month is Revenue Trend Analysis in PostgreSQL. Don't miss this opportunity to elevate your analytical capabilities with a leading database system! Understanding revenue trends is crucial for business success, but effective data analysis can be challenging. Dive into the world of SQL reports and enhance your business growth strategies with PostgreSQL.

Free Course of the Month: PostgreSQL Window Functions

Are you looking for the best way to master SQL window functions? Throughout March 2024, you can access the interactive course Window Functions in PostgreSQL for free. Boost your skills at no cost. Hurry, time is running out! Need a free PostgreSQL course on window functions? You've come to the right place! If you are reading this article, you probably know PostgreSQL is one of the most popular databases in the world.

Free Course of the Month – Common Functions in PostgreSQL

Do you want to be able to use popular PostgreSQL functions and process different types of data more easily? You've come to the right place! Here is the Common Functions in PostgreSQL course. Throughout the month of February, this SQL course is absolutely FREE! You are probably wondering why LearnSQL.com is offering a free SQL course. Well, we've been doing this for a long time. We choose one of our courses every month and give users free access to it.

Free Course of the Month: Basic SQL Practice - Running

Kick off the new year and enhance your SQL skills with January’s free Course of the Month, Basic SQL Practice: Run Track Through Queries! As the new year unfolds, it's a time for reflection and the setting of new goals. A popular resolution among professionals and students alike is to acquire new skills or deepen existing ones. Whether it's learning a new language, mastering a software tool, or enhancing your job qualifications, the start of a new year provides a fresh opportunity for personal and professional growth.

Free Course of the Month – Basic SQL Practice: A Store

This December, seize the opportunity to learn and practice SQL for free with our Basic SQL Practice: A Store course. Designed for an interactive and hands-on learning experience, this course starts with SQL basics and guides you through crafting queries that underpin business intelligence. Ready to get a grip on the fundamentals of SQL and dive into practical database management? Our December Course of the Month, Basic SQL Practice: A Store, is your perfect match!

Free Course of the Month: PostgreSQL Customer Behavior

Ever wondered how top businesses understand their customers so well? The secret lies in data analysis, and we're offering you the key – for free – in our Customer Behavior Analysis in PostgreSQL course! Are you familiar with the basics of PostgreSQL and eager to delve deeper into customer behavior analysis? Our November 2023 Course of the Month, Customer Behavior Analysis in PostgreSQL, has you covered! And the best part?

Free Course of the Month: Blog & Traffic Data

Why practice SQL with real-life scenarios? We'll explain in this article – and we’ll show how you can do it for free during October 2023 with this LearnSQL.com course! SQL is the backbone of many data-driven applications and businesses. It's a powerful language that allows you to interact with databases, retrieve data, and make insightful decisions. If you're looking to improve your SQL skills, our Basic SQL Practice: Blog & Traffic Data course is the perfect opportunity.

Free Course of the Month – SQL Practice Set in PostgreSQL

Do you know the basics of PostgreSQL but still need some practice? Look no further! Here is a great interactive course, SQL Practice Set in PostgreSQL. Throughout the month of September, you have access to it for FREE! We at LearnSQL.com believe that to learn a new skill, you need basic theoretical knowledge and, above all, a lot of practice. It's the same with writing PostgreSQL queries – you need a lot of PostgreSQL practice.

Free Course of the Month – Window Functions Practice Set

Do you want to enhance your SQL skills and learn how to prepare complex SQL reports? Maybe you've learned SQL window functions but need a refresher. This month, our unique SQL course Window Functions Practice Set is completely free! You're probably wondering ‘What's the catch?’. Why do we give something for free to our users? Well... we want to support people like you who are constantly striving to be better.

Free Course of the Month: Write Functions in PostgreSQL

Why learn to write user-defined functions? I’ll explain in this article – and how you can learn for free during July 2023 with this LearnSQL.com  PostgreSQL course! PostgreSQL is one of the most popular databases in the world. This is mainly due to its great functionality and the fact that it’s open source (i.e. free!). Postgres is fast, it runs on multiple systems, and it’s suitable for almost any application.

Course of the Month: INSERT, UPDATE, and DELETE in PostgreSQL

Do you want to be a data engineer or data analyst? Do you work with databases daily and need to expand your skills with the basics of data manipulation? You've come to the right place. For June 2023, our SQL course of the month is PostgreSQL INSERT, UPDATE, and DELETE Commands! Learn SQL for FREE! How do you get this free PostgreSQL course in June? Create a free LearnSQL.

Free Course of the Month – GROUP BY Extensions in PostgreSQL

Do you work with data? Want to be able to create better and more sophisticated SQL reports? Then check out our interactive GROUP BY Extensions in PostgreSQL course. In May 2023, you can complete this online PostgreSQL course for FREE! How can you get this free SQL course in May 2023? Create a free LearnSQL.com account or log in if you already have one. Start the course.

Free Course of the Month: SQL Reports in PostgreSQL

If you are looking for a course that takes your PostgreSQL skills to a completely different level, you've come to the right place. You can learn for free in April! We chose SQL Reporting in PostgreSQL for our Free SQL Course of the Month. It's just awesome – I'll tell you why. Do you want to be even better at SQL? Do you know the basics and want your SQL reports to be even more sophisticated?

Free Course of the Month – PostgreSQL JOINs

Our PostgreSQL JOINs course will help you consolidate your knowledge of working with data from two or more tables in a PostgreSQL database. Throughout the month of February 2023, this awesome SQL course is absolutely FREE! Wondering why we want to give you this SQL course for free? We've been doing this for a long time. Every month, we choose one of our interactive online SQL courses and give users free access to it.

Free SQL Course of the Month – PostGIS

What is PostGIS, and why should you learn it? (Hint: Our SQL PostGIS course is free throughout June 2022!) Did you know databases can store geographic data? This is how interactive maps are made, most often based on PostGIS. In this article, I will tell you what PostGIS is and why it’s worth learning. Moreover, I am going to offer you an awesome online PostGIS SQL course which you can do for free during June 2022!

SQL Course of the Month – Window Functions in PostgreSQL

This is what distinguishes ordinary SQL users from professionals – SQL window functions! Would you like to practice them in PostgreSQL, on one of the best interactive SQL courses in the world, and pay nothing for it? Throughout November, you have access to the Window Functions in PostgreSQL course for FREE. You read it right: you won't pay a penny! What's the catch? Why would someone give you a free course?

Free Course of The Month – SQL Practice Set in MS SQL Server

You have to train a lot to learn a new skill. It is the same with MS SQL Server. Do you want to write good SQL queries? Or maybe you are preparing for a job interview? You've come to the right place! Throughout October you will have access to our amazing hands-on MS SQL Server course for FREE! You probably just thought: “There must be a catch. Why would someone give away SQL courses for free?

Free Course of the Month: SQL Server Revenue Analysis

It is impossible to run a business without a good analysis of revenue trends. But how do you do it effectively? You can rely on good old Excel, but a much better idea is to use SQL and databases. Learn how to create SQL reports and track the growth of your business with MS SQL Server. Here is the course, Revenue Trend Analysis in SQL Server. It’s FREE throughout September!

Free Course of the Month: SQL Reports in SQL Server

This is another in our series of free SQL Courses of the Month. This time, you can learn SQL Reporting in MS SQL Server for free. Do you want to be able to prepare even better SQL reports? Or maybe you have some basic knowledge of SQL Server (one of the major SQL dialects) and would like to go a step further? This is the course for you.

Free Course of the Month: SQL Server Recursive Queries

Do you want to become a SQL expert? To do this, you need to learn SQL CTEs or Common Table Expressions. They can make your queries clearer and more readable. And during July 2021, you can learn CTEs for free using our interactive Recursive Queries in MS SQL Server course! How can you get this free SQL course? Create a free LearnSQL.com account or log in if you already have one.

Free Course of the Month: SQL Server GROUP BY Extensions

Do you create SQL reports? Do you want them to be even better and more effective? Are you working with MS SQL Server and want to expand your query writing skills? Here is a great, interactive GROUP BY Extensions in MS SQL Server course. For the month of June, you can learn and finish this course for absolutely free. How can you get this free SQL course in June?

SQL Course of the Month – SQL Practice Set

Are you starting your adventure with SQL and looking for a place to practice your SQL queries? Or maybe you are preparing for a job interview? I have good news for you. Throughout May, you will have access to our amazing SQL practice course for FREE! Why is LearnSQL.com giving you a free SQL course? Every month, our users get the opportunity to take one of our great SQL courses for free.

Free SQL Course of the Month – Creating Basic SQL Reports

Do you want to create good SQL reports from scratch? Are you looking for a course that will help you spread your analytical wings? What if I told you that throughout April 2021, you could access one of the best SQL Reports courses for FREE? Here it is: Creating Basic SQL Reports. What's the catch? There is none. LearnSQL.com provides one of their courses for free from time to time.

Free SQL Course of the Month – Window Functions

Are you looking for a good SQL window functions course? What if I told you that throughout March, you could access the best window functions course in the world for absolutely FREE? You read that right: you won't pay a dime! Hurry up! Time is running out! But wait – why is LearnSQL.com giving you a free SQL course? Well, we believe sometimes you just have to be good to others.

SQL Course of the Month – SQL JOINs

If you want to really learn SQL, you can’t skip SQL JOINs. They are some of the most fundamental and commonly used features of the SQL language. That’s why SQL JOINs is our February SQL Course of the Month. What makes SQL JOINs so important? I asked Agnieszka Kozubek-Krycuń, Vertabelo's Chief Content Officer, about it. Here's what she said. Is it true that SQL JOINs are one of the foundations of SQL?

SQL Course of the Month – Standard SQL Functions

Are you dreaming of becoming a data analyst? Or maybe you just want to work effectively with your company’s databases? You can – with SQL functions. We’ve selected Standard SQL Functions to be our January 2021 SQL Course of the Month. What will you find inside? I asked Agnieszka Kozubek-Krycuń, Vertabelo's Chief Content Officer, about it. Here's what she said. What are SQL functions? The term reminds me of SELECT or JOIN.

SQL Course of the Month – Customer Behavior Analysis in SQL

Do you run a business? Do you want to squeeze even more out of your data? Start by analyzing your customers' behavior using SQL! Throughout December, you can learn how to do it for free on LearnSQL.com! I asked Agnieszka Kozubek-Krycuń, Vertabelo's Chief Content Officer, about our December Course of the Month, Customer Behavior Analysis in SQL. Here's what she told me. Let's start with the basics: Why analyze customer behavior?

SQL Course of the Month – GROUP BY Extensions in SQL

Do you want to develop your SQL skills? Do you want to get more out of your data and prepare better reports and summaries? The answer is learning to use SQL’s GROUP BY extensions. But how should you go about this? I asked the same question to Agnieszka Kozubek-Krycuń, Vertabelo’s Chief Content Officer. As she explains, the secret is in this November’s free SQL Course of the Month: GROUP BY Extensions in SQL.

SQL Course of the Month: INSERT, UPDATE, DELETE Data

So, you've started learning SQL, and you already know what the SELECT command is and when to use it! Congratulations! Now, it's time to take the next step towards becoming an expert. You need to know the SQL UPDATE, INSERT, and DELETE commands to modify data in your tables. These are the basics that will allow you to work with tables. But what's the best way to learn them? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo.

Did You Know LearnSQL.com Has Free SQL Courses?

Who doesn't like getting something for free? Each month, we give LearnSQL.com users a bit of help in their learning journey – a free, fully interactive SQL course. Since April, we have been giving our users the opportunity to learn SQL for free. Each month, we choose one of our SQL courses and give you full access to it for that month – completely free of charge! Cool, right?

SQL Course of the Month – Analyzing Revenue Trends in SQL

We work hard, we learn SQL, and we develop professionally. But why? For our own satisfaction, but also for money! The knowledge of SQL will increase your income significantly. If you are proficient in SQL, you can better analyze your company's revenue. How? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo. In this article, she answers your questions about our September SQL Course of the Month: Analyzing Revenue Trends in SQL.

SQL Course of the Month – Recursive Queries

Recursive Queries is one of SQL’s more advanced features. You could say they divide SQL users into beginners and experts. But how do you learn recursive queries? And why do you need them, anyway? Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, is here to help. In this article, she answers your questions about our August SQL Course of the Month: Recursive Queries. Recursive queries … that sounds very serious.

SQL Course of the Month – PostGIS

It's summer, and it's travel time ... at least it would be under normal conditions. The pandemic is still going on, but that doesn't stop us from dreaming about distant trips and visits to beautiful places. For now, most of us will have to do it on a map. Did you know that databases can store geographical data? With interactive maps, if you find a nice summer house on the internet, you can accurately track it and plan the best route there.

SQL Course of the Month – Creating Basic SQL Reports

In May, we chose Creating Basic SQL Reports as our course of the month. Why? Because the basis of every successful business is making the right decisions based on proven data and good SQL reports. I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, about this. She knows SQL better than just about anyone and is probably the best person to talk about SQL Reporting. What does it mean to create SQL reports?

SQL Course of the Month – Window Functions

Spring has come. It is nicer outside. It's a great time to learn something new. Which course should you choose? In April, it's worth it to bet on SQL window functions. What are they, what are they used for, and why are they worth knowing? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, these questions. She has a PhD in mathematics and over 10 years’ experience teaching mathematics and computer science at the University of Warsaw.

Tag: Creating Tables

Learn SQL Views in 30 Minutes

Views aren't complicated – if you've got half an hour, we'll get you started writing SQL queries using views! Let's start by answering the question "What is a view in SQL?'. A view is a database object (as is a table, an index, or a stored procedure). Like a table, you can query a view and extract the information in it. It can be used in the FROM clause of a SELECT, and you can reference view columns in clauses like SELECT, WHERE and GROUP BY among other clauses as well.

Tag: Csv

How to Export Data From Microsoft SQL Server to a CSV File

When working with data and databases, it is common to export data for further processing or transport to another database. Follow this article to learn how to export data from Microsoft SQL Server to a CSV file. In this article, we first recall what a CSV file is and why you would want to export data in this format from an MS SQL Server database. Then, we cut to the chase and export data to a CSV file using both SQL Server Management Studio (SSMS) and SQL Command Line (SQLCMD).

How to Export Data from MySQL into a CSV File

A database is a primary platform for working with data and storing data. But often, you must take your data out of the database. Read on to find out how to export data from MySQL database into a CSV file. In this article, we’ll demonstrate how to export data into a CSV file. We’ll start by introducing what a CSV file is and why we use it. Then, we’ll export data from a MySQL database into a CSV file.

How to Import a CSV File to a MySQL Database

CSV files store and transfer data between databases. Read on to find out how easy it is to work with CSV files in a MySQL database. CSV files are one of the oldest data exchange formats and are still heavily used by IT professionals from various domains. It is common for online data resources and different database software to offer their data uploads and downloads in CSV format. In this article, we’ll briefly review what a CSV file is and how to work with it.

How to Export a CSV File From a T-SQL Query

Knowing SQL queries to select data from databases allows you to obtain information easily. However, there are many situations in which we need to export data to another platform or application. The CSV file is a solution to this problem. If you'd like to master complete SQL, try out our interactive SQL from A to Z track. It contains 7 hands-on SQL courses that will take you from a beginner to an advanced SQL user.

Tag: Cte

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.

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.

How to Write a Recursive CTE in SQL Server

A guide to understanding and using recursive CTEs in SQL Server SQL Server offers a lot of powerful tools for working with data, including Common Table Expressions (CTEs). A CTE is a temporary named result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement. CTEs can break down long queries into smaller, more manageable pieces of logic and make them more readable. SQL Server offers recursive Common Table Expressions.

CTE vs. Subquery in SQL: What’s the Difference?

What are Common Table Expressions (CTEs)? Are they the same as subqueries? When would you need to use CTEs? This article looks at the similarities and differences between CTE vs subquery. When I introduce a student to Common Table Expressions, their first reaction is “That’s just a subquery! Why do I need to learn that?”. Let’s answer this question by looking at what you can do with an SQL subquery and what extra advantages there are in using a CTE.

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.

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.

How to Write Multiple CTEs in SQL

Leverage the full potential of the CTE by combining two or more of them in a single SQL query. Common table expressions, or CTEs, can be a powerful SQL tool. When you write two (or even more) CTEs together, this power multiplies. In this article, I’ll show you three ways of writing multiple CTEs: Using two independent CTEs in one SQL query. Using two CTEs where the second CTE refers to the first.

How to Query a Parent-Child Tree in SQL

What are parent-child tree structures in SQL? In this article, we answer that question, talk about query hierarchy, and demonstrate the five most common SQL queries you’ll need for these data structures. Yes, you can use SQL on a parent-child tree structure. I’ll show you how in this article. Along the way, I’ll walk you through five query examples, starting with the easiest and ending with the most complex.

What Is a Common Table Expression (CTE) in SQL?

The common table expression (CTE) is a powerful construct in SQL that helps simplify a query. CTEs work as virtual tables (with records and columns), created during the execution of a query, used by the query, and eliminated after query execution. CTEs often act as a bridge to transform the data in source tables to the format expected by the query. A common table expression, or CTE, is a temporary named result set created from a simple SELECT statement that can be used in a subsequent SELECT statement.

Top 5 SQL CTE Interview Questions

Here are five questions (and solutions!) on CTEs you’ll (probably) be asked at an interview. I’m not saying you will get these SQL CTE interview questions at every job interview. But when you do, they are probably along the lines of the five I’m about to show here. Other than theoretical questions about CTEs, there are not that many variations in the CTE scenarios evaluated by interviewers. Go through these five examples, and you get a good foundation for acing your interview!

What Is a Recursive CTE in SQL?

The article that’ll show you practical examples of using recursive CTEs in SQL. If you’ve heard about SQL’s recursive CTEs but never used them, this article is for you. It’s also for you if you never get tired of recursive CTE examples. Before we dig into recursion, I’ll remind you what CTEs are and what their syntax is. Then I’ll do the same for recursive CTEs. After that, I’ll show you how recursive CTEs work in three examples.

The 7 Best Articles about the SQL Recursive Query

Do you want to learn about recursive queries but don’t know where to start? Here’s our selection of seven articles that should help you with diving into the recursive queries world. I won’t lie to you. Learning and understanding recursive queries can be difficult. But difficult things are usually worth trying. And by learning recursive queries, you’re making sure you know how to work with this very powerful tool.

3 Real-Life Examples for SQL Common Table Expressions

We answer three SQL business questions using CTEs. There are business problems that are often solved in a very roundabout way. While they might get you the correct result, there’s usually a more elegant way to write a solution. Enter the CTEs! They are extremely helpful when it comes to getting a more direct and elegant solution. I’ll show you three business situations where CTEs can be very helpful. You’ll get an idea of when CTEs can be useful.

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.

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.

What Is Advanced SQL?

Are you confused about advanced SQL skills? What are they? This article will explain what advanced SQL can mean, especially as we use it on LearnSQL.com. I’m sure you find the phrases ‘advanced SQL skills’ or ‘advanced SQL topics’ very often. You read one article about advanced SQL and you’re happy with how easy these advanced topics seem to be. Then you talk to someone and you see they consider everything you know as basic SQL knowledge.

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.

SQL CTE Explained

In this article, you will learn about SQL Common Table Expressions (CTEs). This powerful SQL tool will help you simplify complex queries. Additionally, I will introduce you to the two main types of CTEs and some of their use cases.  CTE Primer The Common Table Expression (CTE) was introduced to standard SQL to simplify long, complex queries (especially joins and subqueries). It is a temporary data set returned by a query that contains data separate from the main query.

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.

How to Get Descendants of a Parent in SQL

Want to learn how to handle family trees and find descendants of a parent? By reading this article, you’ll learn how to handle hierarchical data. Finding descendants from a parent is a common problem in SQL. If you imagine a family tree, the basic building block that forms the relationships within it is the parent-child relationship. The parent-child relationship is precisely what defines all hierarchical data. Another example of hierarchical data is the manager-employee relationship.

Where Can I Find Good SQL CTE Exercises?

Find the top online resources for SQL Common Table Expression (CTE) exercises! CTEs allow you to structure and organize SQL queries efficiently, which is essential if you want to advance your SQL knowledge. A Common Table Expression, or CTE, is a SQL syntax that creates a temporary data set. This set contains separate data than the main query, which can typically be referenced or reused in a subsequent query. A CTE is considered temporary because the result is not permanently stored anywhere and only exists for the duration of the query.

What’s the Difference Between SQL CTEs and Views?

SQL views vs. CTEs: What do they do? How are they different? Which one should you use and when? Get your answers here! In SQL, both CTEs (common table expressions) and views help organize your queries, leading to cleaner and easier-to-follow code. However, there are some important differences between them. This article will walk you through several examples of CTEs and views and explain when to use each one.

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.

How to Learn SQL Common Table Expressions (CTEs)

Common table expressions are very useful for organizing, traversing, and improving the readability of long SQL queries.  Moreover, recursive CTEs, which can reference themselves, solve problems that cannot be addressed with other queries. But how do you master common table expressions in SQL? In this article, I discuss the most effective strategies for learning CTEs and suggest how to address the common challenges of learning common table expressions on your own.

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.

How CTEs Work

The SQL language offers a feature named Common Table Expressions, or CTEs. Also known as WITH clauses, CTEs are a fairly new addition to SQL. They help you break longer queries into smaller chunks, making your queries much easier to understand. Read the article to find out how to use CTEs and how they differ from traditional subqueries. Common Table Expressions (CTEs), which are essentially named subqueries, were first mentioned in the SQL standard between 1999 and 2000.

SQL CTEs Explained with Examples

Learn how you can leverage the power of Common Table Expressions (CTEs) to improve the organization and readability of your SQL queries. The commonly used abbreviation CTE stands for Common Table Expression. To learn about SQL Common Table Expressions through practice, I recommend the interactive Recursive Queries course at LearnSQL.com. It contains over 100 hands-on exercises on simple and complex recursive CTEs. What does a CTE do? Why might you want to use one in your SQL code?

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.

What Is a CTE?

After mastering statements like SELECT, DELETE, INSERT, and GROUP BY, you might search for ways to improve code maintainability, reproducibility, and readability. At that point, you will probably start learning about modern SQL concepts that were introduced in the early 2000s. One such SQL technique is the CTE? (common table expression) —?a temporary named result set. In this article, you will learn what a CTE is and how to use it to improve the maintenance and the readability of your code.

How to Draw a Christmas Tree in SQL

You can use SQL to manipulate all kinds of data, from huge analytical queries to brief single-purpose statements. But you can also use SQL just for fun, without any business requirements stifling your creativity. So, get out your jolly hat and prepare to sing O Christmas Tree as we create some quirky art with plain old SQL. Today, we’re going to generate some holiday-themed ASCII art, just for fun. That’s right.

Simplify SQL Code: Recursive Queries in DBMS

Hey SQL users! Are you repeating the same query in every report? Are your queries getting too complicated? Use recursive queries to simplify SQL code! Too many SQL reports can lead to clutter on your desktop and in your head. And is it really necessary to code each of them separately? Ad-hoc queries can share much of the same SQL code with managerial reports and even regulatory reports. Suppose you’ve been writing basic SQL code for a while.

How to Organize SQL Queries with CTEs

Common table expressions (CTEs) allow you to structure and organize SQL queries. Knowing how to organize SQL queries is a necessity when you begin to move deeper into SQL, so if you want to become an SQL master, you need to know CTEs. The SQL CTE has been part of standard SQL for some time now. CTEs – which are also called WITH statements – are available in all major RDBMS.

Long SQL Query vs. Recursive SQL Query

Recursion is one of the central ideas in computer science. We can define it as a method for solving problems where the solution of the problem depends on solving a smaller instance of a problem. If this sounds complicated do not fret, in this article we will learn about recursion in SQL that you can practice and deepen in Vertabelo Academy. Recursion is a way of solving hierarchical problems we find in data with common SQL.

How Recursive Common Table Expressions Work

Recursive Common Table Expressions are immensely useful when you're querying hierarchical data. Let's explore what makes them work. Common Table Expressions (CTEs) are some of the most useful constructions in SQL. Their main purpose is improving query design, which makes queries easier to read. One of the reasons CTEs are so popular is that they let you divide longer queries into shorter subqueries. These are easier to read and edit.

How to Organize SQL Queries When They Get Long

The first long SQL query you’ll have to deal with is likely to be hard for you to structure and understand. These five tips will teach you the best way to organize SQL queries, i.e. write and format them. As we all know, SQL queries are essential to database management. Without them, it would be extremely difficult to find and work with the information in a database. Query length depends on the type of information we need and the size of the database.

Improving Query Readability with Common Table Expressions

What is a Common Table Expression, or CTE? Where do you use them, and why? This post answers your questions. Simply put, Common Table Expressions (also known as WITH clauses) are essentially named subqueries. They also provide additional features like recursion. If you're new to subqueries, I recommend you read the SQL Subqueries article before continuing. The main purpose of Common Table Expressions is to improve the design and readability of an SQL statement.

Tag: Data Analysis

Does Data Analytics Require Coding

Thinking about a future in data analytics? You might be pondering the need for coding skills. Is it necessary to be good at programming? As the worlds of data analytics, technology, and data science merge, the importance of coding becomes clearer. It’s crucial to understand which programming languages are key and how much expertise you need, making the journey into this vibrant field less daunting. In this article, we're going to focus on the importance of coding, particularly SQL, for data analytics.

Efficient Data Analysis: Leveraging SQL with R

This article delves into the nuances of using SQL with R in data analysis. It offers insights and practical examples that demonstrate the effectiveness of this combination. By integrating SQL with R, analysts can leverage the strengths of both languages. This helps them perform comprehensive data analyses, going from initial data retrieval to complex statistical modeling and visualization. To kickstart our exploration of the dynamic duo of SQL and R in data analysis, it's essential to grasp how these two powerful tools can revolutionize the way we handle, manipulate, and interpret vast datasets.

Integrating SQL with Python for Data Analysis

Integrating SQL with Python isn’t difficult. The two tools work together to combine the information-processing power of relational databases with the flexibility of a programming language. In this article, I will discuss the benefits of data analysis using SQL and Python, with real-world coding examples. Why do most of the best data analysis tools on the market – such as Tableau and Power BI – include both SQL and Python in their toolboxes?

Using SQL in Data Warehousing

SQL is a key player in organizing and analyzing data in data warehouses. In this article, I'll introduce you to the basics of SQL in data warehousing. We’ll learn how this powerful language helps manage large datasets, making your work easier and more productive. Whether you're a student diving into the world of technology or an experienced specialist navigating the domain of data, understanding the concept of data warehousing is fundamental.

Analyzing Social Media Data with SQL

Diving into the world of SQL social media analysis? This guide will help you start using SQL to analyze and interpret data from social media platforms. Get ready to transform your approach to digital data and unlock new possibilities in social media analytics! Welcome to the exciting world of SQL and social media analysis! If you're new to this field, you're about to discover how powerful a tool SQL can be in understanding the vast sea of data generated on social media platforms every day.

SQL and Power BI: Transforming Data into Insights

The need for powerful tools that enable efficient data analysis and visualization has never been greater. Enter SQL and Power BI, a potent duo that enables businesses to maximize the value of their data assets. First, let’s explain what SQL and Power BI are; then we’ll discuss how and why they make such a great pair. SQL, or Structured Query Language, allows you to communicate with databases, making it the foundation of data management.

SQL for Data Analysis: 15 Practical Exercises with Solutions

Are you new to the world of SQL and eager to unlock the power of data analysis?. In this article, we'll improve our SQL skills through 15 practical, hands-on exercises designed specifically for beginners. Because when it comes to SQL, practice truly makes perfect! We’re going to shine a spotlight on the critical domain of data analysis, where SQL takes center stage. SQL, or Structured Query Language, plays a pivotal role in data analysis.

How to Prepare for the SQL Assessment Test

In this guide, I’ll walk you through the essentials of SQL assessment preparation, from understanding database management to mastering data analysis and SQL commands. Let’s dive in and set you on the path to success. In today's data-centric world, mastering SQL proficiency holds paramount importance. Whether you're a seasoned database manager or a newbie exploring the realm of database management, gearing up for an SQL Assessment is crucial. Stepping into the world of SQL can be both thrilling and challenging.

How SQL Can Help You Understand Your Clients Better

In this article, we will delve into how SQL can help businesses analyze customer data, uncover patterns, and make informed decisions to meet their clients' needs. Managing and understanding clients is crucial for any business, and this requires data. Client data, such as purchasing habits, preferences, and feedback, is typically stored in databases. To access and analyze this data, you need to be proficient in SQL, the language designed for managing and querying data in databases.

Python vs. SQL for Data Analysis

You surely have heard about SQL and Python. Maybe you’ve even worked with one of those languages. Both have strengths and weaknesses. When it comes to data analysis, which should you use? This article will demonstrate how Python and SQL are useful for data analysis and how knowing both languages can boost your data analysis journey. Decided to get into data analytics? Great! An increasing number of companies are looking for people who can analyze data and draw conclusions from it.

How AI & SQL Can Accelerate Your Data Analysis Workflow

Did you know that using AI for data analysis can be a total game changer for SQL developers and data analysts? In this article, we’ll learn about how AI can help you level up your data analysis skills and why it’s a must-have tool in every data professional’s toolkit. Artificial Intelligence (AI) has emerged as a game-changer in the workforce, transforming industries and redefining how professionals deal with data. Specifically, the use of AI for data analysis is becoming increasingly critical in making informed decisions.

SQL for Data Analysis Cheat Sheet

Welcome to our SQL for Data Analysis Cheat Sheet — a must-have resource for anyone looking to harness the power of SQL in the realm of data analysis. Whether you're a data enthusiast, a business analyst, or a seasoned data professional, this cheat sheet is designed to empower you to extract valuable insights from your datasets. Inside, you'll find a carefully curated collection of SQL commands and tips that will elevate your data analysis game.

Best SQL Books for Data Analysis

In the world of data analysis, SQL is a powerful tool. It's a language that helps professionals find, organize, and analyze the data stored in databases. If you're looking to learn this important skill, you've come to the right place. This article will guide you through the best SQL books for data analysis, whether you're just starting out or already have some experience. SQL (Structured Query Language) is a standard language used for working with databases.

SQL for Data Analysis: What Should I Learn?

You may already be aware of SQL's importance in data analytics. But what features of SQL are important to data analysis and where can you learn them? In this article, we will answer your questions. Before we talk about using SQL for data analysis, it helps to know what we’re talking about. So, let’s define these two things. Structured Query Language (SQL) is a programming language that is used to manage data in relational databases.

Google BigQuery SQL Syntax: A Comprehensive Guide

What is Google BigQuery? What can it do for your organization? Is BigQuery SQL a valuable skill? Where can you learn it, and where can you get some practice? Very few organizations today are not computerized. Many processes now make use of the IoT (Internet of Things), where all kinds of devices are networked and continually feed real time data into computer systems. The result is a vast amount of data available for decision-making.

Why Do You Need SQL to Work With Google BigQuery?

Data is just as important to your business as investing or accounting; that’s why many people use Google’s BigQuery data warehouse. In this article, we'll discuss why you should learn SQL if you want to start using BigQuery. Unleash the power of your data! In the ever-growing landscape of data-driven decisions, organizations are continuously on the lookout for tools that can help them handle and analyze their data efficiently. Enter Google BigQuery: a powerful, Cloud-based data warehouse designed to store and analyze massive datasets in record time.

Why Is Data a Valuable Resource for Your Business?

How do you build an effective data resource and make it work for you? In this article, I'll look at why data is so important to any organization and how to make the most of your data resources. Bad decisions are almost always based on incorrect or incomplete facts. Good decisions keep your organization competitive. In a nutshell, that’s why data is such an important business resource. Ever since the dawn of civilization, our ancestors have known the value of information.

Why SQL Is the Perfect Database Language

Which programming language should you learn if you want to work with databases? We’ll explain why SQL is the top choice! Learning a database language can be an incredibly valuable skill in today's data-driven world. But with so many options out there, it can be difficult to know where to start. In this article, we'll make a compelling case for why SQL is the ideal choice for anyone looking to dive into the world of databases.

Top 7 Advanced SQL Queries for Data Analysis

Explore essential advanced SQL queries for data analysis. Structured Query Language, or SQL, is an indispensable tool for data analysts. Most people pick up the language relatively quickly and can begin in-depth data analysis after just a few lessons. Because of this, many data analysts tend to stay in the beginner/intermediate level of using SQL. This level of understanding allows you to “get the job done”, but it might not be the most efficient way to write a query.

Learn SQL for Data Analysis with LearnSQL.com

Updated on: December 1, 2023 Discover how to learn SQL for data analysis and start making sense of your data today. Our guide provides a clear and simple SQL learning path for data analysts, helping you query databases and analyze data with ease. Whether you're starting from scratch or looking to polish your skills, we'll help you every step of the way. When I was in high school, I planned to go to college and major in interior design.

Why You Need Analytical Skills to Get Promoted at Work

Do you wonder if analytical skills might benefit you in your job? Are ‘analytical skills’ the same as data analytics? Is SQL a useful analytical skill? Read the article to answer these questions. Analytical skills allow you to better understand problems in your work; good analytical skills bring many benefits to your career. The term ‘analytical’ refers to a wide range of traits and capabilities, making it sometimes ironically vague and general.

Roadmap to Becoming a Data Analyst

What is a data analyst? What are their daily duties, and what skills do they need? In this article, I discuss the role of data analysts and share a step-by-step guide on how to become one. As organizations start to realize the value of their data on their customers, target audience, competitors, suppliers, and other market players, the role of data analysts becomes more important. To become a successful data analyst who can bring real value to the organization, you need to possess a specific set of skills.

How to Learn SQL for Marketing Analytics With LearnSQL.com

SQL is a valuable tool for any experts wanting to make data-driven decisions. Marketers are no exception. Let's explore how to design an effective learning path for SQL in marketing. SQL for marketing analytics is used to understand customers better and to increase the effectiveness of marketing campaigns. If you work in marketing and want to join other marketing experts who have already benefited from this tool, you need to learn SQL.

Use SQL for Data Analysis With the New Google Analytics 4

As Google is sunsetting its Universal Analytics in favor of Google Analytics 4, data analysts need to adapt and learn how to get the most from the new tool. In this article, I'll discuss how to enhance your data analysis by using SQL with Google Analytics 4. Universal Analytics by Google has been helping data analysts and marketers in all industries everywhere understand their audience better. However, Google recently announced they would stop their support of Universal Analytics on July 1, 2023.

These SQL Queries Will Help You With Data Analysis

Need to streamline your everyday data analysis tasks? This article explains how basic SQL queries can help. If you are planning a corporate career or any field that involves working with data, you must have come across SQL, or Structured Query Language. SQL was first developed in the 1970s and it continues to be the industry standard for database interactions. Many of you may already have decided to learn this language, given how powerful it is.

5 Tips for You From a Senior SQL Data Analyst

Are you looking for tips for becoming a better data analyst? Do you want to know about the mistakes and issues you may face? I have collected five tips for your everyday work based on my experience as a data analyst. You may have already read about what data analysts do, how much they earn, and how to become one. However, there is more to it than just becoming a data analyst.

Why Should Every Data Analyst Know SQL?

In the 1980s and 90s, it was the emergence of ERPs, processing a few thousand transactions a day. Now, sophisticated Cloud-based systems work with billions of transactions each day. How data is captured and handled has come a long way! Anybody who understands how to use this data has an edge. The good thing is that while the technology working in the background has become more complex, we don’t necessarily need to understand the underlying system’s details to use it.

Are You Ready to Become a Data Analyst?

Data analysts enjoy strong career prospects. Do you have the skills required for this role? Let’s find out! If you enjoy working with data, searching for interesting patterns and valuable insights, you may wonder “Should I become a data analyst?” In this article, I’ll explain what data analysts do and what skills a successful data analyst needs. What Does a Data Analyst Do? Data-driven organizations rely on specialists who know how to get value out of data.

Here’s How I Started Creating SQL Reports

Once upon a time, there was a girl who was just starting her adventure with learning SQL. As a marketer, one of her tasks was writing reports. Previously, she used Excel, a calculator, and written notes to prepare the reports her boss required. One day, it turned out that she could do her job much faster and easier. That was the day she read about SQL reports for the first time.

Here’s Why You Should Use SQL for Sales Analytics

Would you like to understand how your sales efforts play out so that you know where to put your focus? Do you want to empower your sales teams with sales analytics? This article shows you how you can use SQL to use your sales data to your advantage. If you work in sales, understanding the activities that produce results has financial consequences for you, your team, and your company. This is where sales analytics can really help you.

Still Using Excel for Data Analysis? See Why SQL Is Better!

Are you working with data and still using spreadsheets? Many people think that only programmers or professional data analysts can leverage SQL for data analysis. In this article, I’ll show how people with no IT background can use SQL for their daily work tasks. Not all people working with data have the corresponding job titles like data scientist, data analyst, or data engineer. Following the data democratization trend, almost all office workers do something with data as part of their daily duties – marketers analyze advertising campaigns, HR specialists analyze employee dynamics, auditors analyze credit portfolios, etc.

Read These 5 Data Analysis Books to Jump-Start Your Career

Do you want to pivot into a data analyst role, but you are unsure where to start? Do you do analytics in your job and would like to learn more about the big picture of data? Are you looking for a great data analysis book to read? In this article, you will find our selection of the best books on data analysis! If you are a business professional thinking about picking up data analytics skills, you may be wondering how you should start.

Top 10 Tools for Business Analytics

Business Analytics is one of today’s hottest career fields. However, success as a business analyst requires that you learn the right skills and software programs. Let’s see what tools you should know if you want to be a business analyst. With the world generating immense amounts of data – and having systems in place to capture and manipulate that data to fuel business growth – job opportunities for business analysts are only going to grow.

Why You Should Use SQL in Marketing Analytics

Have you been wondering how you could use SQL in your marketing data analysis work? Would you like to create SQL reports to guide your marketing decisions? In this article, you will learn how to use SQL for marketing through plenty of use cases. Are you a marketing professional wanting to better understand the results of your marketing efforts? Do you want better means to prove your point and demonstrate the value you create?

How Much Do Data Analysts Earn in 2021?

How Much Do Data Analysts Earn in 2021? How much does a data analyst earn? We did some data analysis ourselves. Nothing fancy, but it will give you some extra motivation for learning SQL for your data analyst gig. Data, data everywhere! We live in the world of (big) data. Having data is just the first step. Knowing what to do with it, how to interpret it, and what insights it holds, is true greatness.

Why You Should Work in a Data-Driven Company

Does accessing and using data collected by your company feel painful? Have you heard about data-driven companies? Working in a data-driven company may give you the ownership and the opportunities to use your company’s data. Read our article to learn more! If you work in a company, chances are that you want to do data analysis to solve problems. However, this is often not easy. You face many obstacles, impeding access to the data you need.

How SQL Can Help You Democratize Data in Your Company

Are you drowning in an ocean of data but lack the staff to find the treasures in it? Do bottlenecks clog your data and reporting processes? Have you heard about data democratization and wondered what all the fuss is about? In this article, we answer your questions! If you are a part of an organization that works with data, limited access is one of your biggest bottlenecks. It impedes data-related processes and prevents you from generating insights about your business.

Skills Every Data Analyst Should Have

If you’re a student looking for career advice or a specialist seeking new job opportunities, find out if a data analyst job is something worth considering. In today's article, I explain the essential skills required for data analysts and benefits that come from performing such a job. What Is a Data Analyst? Let’s start by defining exactly what a data analyst is. A data analyst is someone who uses their skills to collect, analyze, and report insights from company data.

Data Analyst vs. Data Engineer: A Full Comparison

Do you want to become a data analyst? Or maybe you dream about being a data engineer? Can't make up your mind? I'll help you. Read about the two roles’ history, their market situation, and the skills you need to become one. You already know that it's a good idea to enter the data world and work with databases. But how to do it? Behind which door is the better career waiting for you?

Why Does Your Company Need Data Analysis?

Data is the new gold. That is what the biggest in the business say, knowing the value of the data, the analyses, and the conclusions they bring. If you are wondering why your company needs data analysis and what value it could bring to your business, then this article is for you. Historically, many companies have gone into analytics mainly through financial and accounting data to improve revenue, reduce costs, and eventually increase profitability.

Analyze Small Datasets with SQL

If you think SQL data analysis is useful only when a business is generating millions of rows of data – that SQL cannot help you if you are generating a limited dataset – think again and read on! There is so much talk about how SQL is useful in analyzing Big Data that sometimes the applications of SQL data analysis for small datasets can go unnoticed. Having worked with early-stage businesses – which have just started generating data through daily transactions – as well as big established clients generating terabytes of data, I can tell you for sure that SQL can be an extremely handy tool for just about any business.

6 Advanced SQL Queries for Analyzing Financial Data

Are you an advanced SQL user who’s new to finance? Do you want to learn how to use your knowledge to analyze financial data? The article will give you some guidance. You probably know that SQL is a potent tool for analyzing all sorts of data. The bigger and more complex data, the more beneficial SQL becomes. In certain situations, financial data can be very complicated; producing a sophisticated analysis requires sophisticated tools.

Why Use SQL Over Excel

SQL is replacing Excel in many fields, and data analysis is certainly one of them. If you are still using Excel as a data analyst, you are missing something very valuable. SQL can make your life easier, as it's more efficient and faster than Excel. So, how and from where can you learn SQL? How Can SQL Help Data Analyst? You can use SQL to help you with the following work:

SQL Indexing 101

Indexes are one of the most misused and misunderstood entities in physical database design. A good understanding of indexes and how they solve database performance problems is necessary for any database novice. In this article, we'll look at basic database indexes and their role in database development. To picture what an index is, consider a textbook. At the end of most textbooks is an index listing all the terms one can find in the text and the pages on which they appear.

How to Use a SQL Wildcard

SQL wildcard allows us to filter data matching certain patterns in SQL. We use SQL wildcards with the LIKE operator in the WHERE clause of a query to filter data. In this beginner’s article, we’ll look at everything you need to know about basic SQL wildcards. If you like playing cards, then you know that wildcards can substitute any other card in your deck. Similarly, SQL wildcards can substitute one or more characters.

Our Picks for 2020’s 7 Best Online SQL Schools

If you’re looking for the best online SQL courses but aren’t sure where to start, you’re in the right place. I evaluated the top 7 ranked SQL schools available online to help you find the right solution. While summer is a great time to relax and get away from work, it’s also an excellent opportunity to learn new skills – like SQL! Thanks to SQL schools putting their courses on the internet, learning new tech skills is super easy and you can choose from a variety of formats to suit your needs.

Why Learn SQL Over the Summer

Think summer is reserved for flying to warm places and hanging out at the beach? Sure! But it's also a great time to learn new skills that you haven't had time for. If you recently graduated from high school and want to get a head start on computer programming for college, learning SQL over the summer is a great opportunity. You have nothing to lose and everything to gain—SQL is actually really easy to learn, especially with so much free time over the summer.

Improving Slow Query Performance: When Runtime Matters

As SQL users, we usually focus on writing queries that return correct results. However, there are more things to consider when you're writing a query; one of them is query performance. In this article, we'll look at some examples where query response time is critical. Scene One: 911 Call Center Let's suppose we're at a 911 call center, when the phone rings. One of the operators answers the call; a witness reports that a man has been shot.

Converting Subqueries to Joins

Not all queries are alike, especially in terms of performance. In this article, we'll look at how you can convert SQL subqueries to joins for improved efficiency. When should I use SQL subqueries? Great question! Unfortunately, there's no concrete answer. SQL beginners tend to overuse subqueries. Typically, once they find that SQL construction works in one situation, they try to apply that same approach to other situations. It's only natural.

Learn to Write a SQL Correlated Subquery in 5 Minutes

If you’re familiar with the famous Russian nesting doll, then SQL correlated subqueries should be a peace of cake to understand—subqueries are just queries nested within queries. An SQL subquery is often called an “inner” query; the main query is usually called the “outer” query. This article covers everything you need to know about correlated subqueries. What Exactly is a SQL Correlated Subquery? A correlated SQL subquery is just a subquery that is executed many times—once for each record (row) returned by the outer (main) query.

How to Become a Database Analyst

Curious about becoming a database analyst? Maybe you've taken some database courses at university and they really struck a chord. Or maybe you learned online. Now you're thinking about making a career out of working with databases. Where would you start? What should you expect at each phase of your professional development? In this post, we'll explore the challenging and exciting world of databases analysis. We'll go from the very beginning of a career to the apex of professional success.

Extracting Data From a String: SPLIT_PART in PostgreSQL

Learn how to use split_part in PostgreSQL to extract data from strings. Quite often, we’d like to extract parts of a string when working with text values. A common example is when we have a full name and need to retrieve only the last name. In this article, we’ll examine how to do it using split_part in PostgreSQL, i.e. a string-related function that can be used to extract a substring.

Statistics in SQL: Dependencies Between Discrete Variables

In my previous article, we looked at how you can calculate linear dependencies between two continuous variables with covariance and correlation. Both methods use the means of the two variables in their calculations. However, mean values and other population moments make no sense for categorical (nominal) variables. For instance, if you denote "Clerical" as 1 and "Professional" as 2 for an occupation variable, what does the average of 1.5 signify?

Analyzing Survey Data: Explore Results Using SQL

Excel is a powerful beast that lets you analyze complex data. Yet, operating on big chunks of data can sometimes be a daunting task. Let's take a look at how SQL can help. Today, we'll tackle a common problem with importing data to an SQL database, using a real-life example. Suppose your company conducted a survey on the most popular programming trends and preferences, striving to meet the expectations of its users.

SQL Hacks To Control Family Budget On Black Friday Weekend

If you’re in the US, chances are you’ve been eagerly awaiting the approach of Black Friday just as much as Thanksgiving. Though the shopping frenzy takes hold of nearly everyone, some people have to stick to their budgets and shop prudently. In this article, we’ll take a look at how generating an SQL report can help you track how much your family spent shopping on Black Friday. Storing Black Friday Purchases in a Database Before we can create an SQL report, we first need some data we can use.

SQL Reporting Guide for Business Professionals

Working with the financial aspects of large and small enterprises can be a daunting task for a business professional. In this article, we'll look at several ways of constructing the perfect SQL report. You've probably already heard about SQL from your colleagues or in other areas of your career. If you're here, you've likely concluded that learning SQL will make your professional life easier – and you're right!

Statistics in SQL: Calculating Frequencies & Histograms

Database and Business Intelligence (BI) developers create huge numbers of reports on a daily basis, and data analyses are an integral part of them. If you wonder whether you can perform statistical analysis in SQL, the answer is ‘yes’. Read my article to learn how to do this! Statistics are very useful as an initial stage of a more in-depth analysis, i.e. for data overview and data quality assessment. However, SQL statistical analysis possibilities are somewhat limited as there are not many statistical functions in SQL Server.

Tag: Data Analyst

Is the Data Analyst Still in Demand in 2024?

In 2024, the demand for data analysts will rise as businesses increasingly rely on data to make strategic decisions. In this article, we explore the importance of data analysts in shaping the future of data analysis. With the rise of AI, many wonder if the demand for data analysts will remain strong. After all, the data analytics industry has witnessed a remarkable transformation. It’s evolved into a pivotal force driving decision-making processes across various sectors.

Does Data Analytics Require Coding

Thinking about a future in data analytics? You might be pondering the need for coding skills. Is it necessary to be good at programming? As the worlds of data analytics, technology, and data science merge, the importance of coding becomes clearer. It’s crucial to understand which programming languages are key and how much expertise you need, making the journey into this vibrant field less daunting. In this article, we're going to focus on the importance of coding, particularly SQL, for data analytics.

Building a Data Analyst Portfolio: All You Need to Know

In a competitive job market, it is not enough to simply have the necessary skills; you must also demonstrate them. This is where a well-crafted data analyst portfolio comes into play. In data analytics, a portfolio is more than just a collection of projects; it serves as proof of an analyst's abilities and is critical to standing out. It demonstrates concrete capabilities in data cleaning, analysis, and visualization as well as the ability to effectively communicate insights.

Business Analyst v. Data Analyst: Roles & Career Paths

Are you interested in working as a data analyst or business analyst? What’s the difference between these two roles? We explain the data analyst vs. business analyst debate in this article – and give you a pathway for success in either job. The demand for individuals skilled in decoding complex data has reached new heights in the ever-changing business landscape. Among the many roles available, business analysts and data analysts each have their own responsibilities, skill sets, and career paths.

Data-Driven Career Choices: Database Student

Choosing a career is one of the most important decisions you'll ever make. A data-driven career is one of the best ways to secure your future; today's trend is to store and make use of more and more data in every field. In this article, I'll look at some of the choices available. We're living in an era where the quality and quantity of data is expanding exponentially. In almost any career you choose, you'll need to leverage data to make effective decisions.

SQL for Data Analysis: What Should I Learn?

You may already be aware of SQL's importance in data analytics. But what features of SQL are important to data analysis and where can you learn them? In this article, we will answer your questions. Before we talk about using SQL for data analysis, it helps to know what we’re talking about. So, let’s define these two things. Structured Query Language (SQL) is a programming language that is used to manage data in relational databases.

Google Analytics and SQL

Google Analytics is a very popular tool among website and blog owners alike. With a simple and quick setup, it lets you gather data about your web page visitors easily. However, did you know that you can export data from Google Analytics to create your own SQL reports? Read this article to find out how. Google Analytics is an extremely popular and powerful solution that lets you collect and analyze various kinds of information about your website.

Should I Learn SQL as a Data Analyst?

So, you are a data analyst—someone who relies on data. You like to gather, clean, and transform data and come to conclusions based on data. You are a data detective. Which tool do you choose to do your job in an elegant, reproducible, and simple way? Excel? R? Python? Or should you learn SQL? Stay tuned! In this article, I will explain why SQL is a must-have skill for data analysts.

Statistics in SQL: Calculating Frequencies & Histograms

Database and Business Intelligence (BI) developers create huge numbers of reports on a daily basis, and data analyses are an integral part of them. If you wonder whether you can perform statistical analysis in SQL, the answer is ‘yes’. Read my article to learn how to do this! Statistics are very useful as an initial stage of a more in-depth analysis, i.e. for data overview and data quality assessment. However, SQL statistical analysis possibilities are somewhat limited as there are not many statistical functions in SQL Server.

Tag: Data Analytics

Does Data Analytics Require Coding

Thinking about a future in data analytics? You might be pondering the need for coding skills. Is it necessary to be good at programming? As the worlds of data analytics, technology, and data science merge, the importance of coding becomes clearer. It’s crucial to understand which programming languages are key and how much expertise you need, making the journey into this vibrant field less daunting. In this article, we're going to focus on the importance of coding, particularly SQL, for data analytics.

Tag: Data Cleaning

Data Cleaning in SQL

Data cleaning is an important part of any data analysis. Here we’ll discuss techniques you can use to do data cleaning in SQL. I find it nearly impossible to focus on work when my desk is a mess. If it’s cluttered with paper, coffee mugs, or random toys my daughter has somehow snuck into my office, there is no chance I will be able to get anything done until my desk is back in order.

Tag: Data Democratization

How SQL Can Help You Democratize Data in Your Company

Are you drowning in an ocean of data but lack the staff to find the treasures in it? Do bottlenecks clog your data and reporting processes? Have you heard about data democratization and wondered what all the fuss is about? In this article, we answer your questions! If you are a part of an organization that works with data, limited access is one of your biggest bottlenecks. It impedes data-related processes and prevents you from generating insights about your business.

Tag: Data Driven

Why You Should Work in a Data-Driven Company

Does accessing and using data collected by your company feel painful? Have you heard about data-driven companies? Working in a data-driven company may give you the ownership and the opportunities to use your company’s data. Read our article to learn more! If you work in a company, chances are that you want to do data analysis to solve problems. However, this is often not easy. You face many obstacles, impeding access to the data you need.

Tag: Data Driven Organization

How SQL for Business Can Boost Profit and Effectiveness

Are you ready to unleash the power of SQL and transform your business? In this article, we'll look at all of the ways SQL can improve your company's performance, from decision-making capabilities to operational efficiency. Having the correct tools to traverse the sea of information is critical in today's data-driven corporate climate. Structured Query Language, or SQL, is an essential tool for this task—and it’s one that has endured the test of time.

How SQL supports data-driven organization

Typical business users make decisions based on gut feelings, but this can't get them so far. In this article, we'll look at how learning to write basic SQL queries helps your company become a data-driven organization. Businesses face many decisions. Do we increase our advertising budget in one region or the other? Are certain products selling quickly enough? What we should do if they aren't? Most of these decisions are driven by intuition, but organizations that make the most business impact use data-driven decision-making.

Tag: Data Engineering

How to Become a Big Data Engineer

What is a Big Data engineer, and how is their skill set different from a data engineer? In this article, we explore the tools and platforms you’ll need to master as a Big Data engineer. To move from being a regular data engineer to a Big Data engineer, you need to acquire several new skills and learn to use several new tools. The good news is that Big Data still lets you use your good old SQL skills to manipulate and get information from data repositories.

Want to Get a Data Engineering Job? Learn SQL!

So, you want to be a data engineer, but you don't know how to get there. In this article, we’ll help you understand the skills you'll need for different types of data engineering jobs. You’ll also find some data confirming that data engineer jobs are a good career choice. Data engineering and various types of data engineer jobs have become very popular in recent years. And for good reason: Next to data science, data engineering is one of the fastest-growing branches of IT.

What Is the Future of the Data Engineer?

If you are wondering about the future of data engineering as a career and whether it is worth becoming a data engineer, then this article is for you. Here, I cover how lucrative the prospects are for data engineering and how you can get started and thrive in the domain. “Data” is probably one of the most used terms in our everyday business language today. A data engineer plays a pivotal role in developing the infrastructure required for data-related actions.

7 Things Every Data Engineer Should Know

People generate massive amounts of data every day. To get insights from data, organizations need to capture and process them efficiently. That is when data engineers are called up. In this article, I’ll discuss the data engineering role and the skill set necessary to succeed in the role. As the world generates more and more data every year, the IT industry creates new roles to deal with it. These roles include data analysts, data scientists, machine learning engineers, and data engineers.

An Overview of MS SQL Server Data Types

SQL Server data types define what can be stored in a column, local variable, expression, or parameter. It is essential to pick the right data type. Ultimately. your choice of data types affects the whole database. Read on to learn about all of the data types available in MS SQL Server. In this article, we’ll cover numerical, text, and date and time data type categories in detail. We’ll go through their syntax, storage size, and typical use cases.

New to Data Engineering? Don't Make These Mistakes

It's best to learn from the mistakes of others. This advice also works for data engineering. In this article, you'll find tips to help you advance your career and avoid common data engineering mistakes. The data revolution has produced tremendous opportunities and created various high-paying jobs related to the collection, maintenance, and manipulation of data. Data engineering is one of the most lucrative and interesting jobs of this family.

Primary Key vs. Unique Key: Explaining the Differences

When designing a database, we often need to decide between defining a primary key vs. a unique key. Both of them are crucial during the design and further phases of a database. They allow us to uniquely identify each row, ensure the uniqueness of values in the column(s), and more. Let’s take a deep dive to learn more. This article will go through the primary and unique keys, their functions, and features.

Data Analyst vs. Data Engineer: A Full Comparison

Do you want to become a data analyst? Or maybe you dream about being a data engineer? Can't make up your mind? I'll help you. Read about the two roles’ history, their market situation, and the skills you need to become one. You already know that it's a good idea to enter the data world and work with databases. But how to do it? Behind which door is the better career waiting for you?

What Is a NOT NULL Constraint in SQL?

SQL has several ways of dealing with NULLs. In this article, we’ll focus on the NOT NULL constraint and other NULL-related clauses. Understand this and you’ll take an important step in your SQL growth! Before we get straight into the NOT NULL constraint, let’s quickly define what NULLs and constraints are. NULL values are a central concept in SQL databases. The idea behind a NULL value is simple: a NULL value means that we do not have a known value for that field.

What Is a Unique Constraint in SQL?

To ensure the uniqueness of data in a database, we use the SQL UNIQUE constraint. In this article, we’ll discuss how, when, and why to implement it. The idea of a unique constraint is not unique to SQL; it’s a familiar concept in real life, although we probably call it something else! For example, think of ID numbers. There can be only one social security number (SSN) per person and each one must be unique.

Data Types in SQL

Read this article and learn the ABC of SQL data types. Data types are used to define the type of data stored in a database. However, there are related concepts that a good SQL developer should know: data type conversion, what operations are possible between different data types, date arithmetic, etc. SQL also provides functions that manipulate values of different data types (i.e. functions for string data, date and time data, etc.

What Is Auto-Increment in SQL?

In this article, we’ll learn the basics of the auto-increment feature of SQL: what it is and how to use it efficiently. One of the many features offered by SQL is auto-increment. It allows us to automatically generate values in a numeric column upon row insertion. You could think of it as an automatically supplied default value – the next number in a number sequence – that’s generated when the row is inserted.

Winter 2021 Track of the Season: Creating Database Structure

New year, new challenges, and ... a new SQL Track of the Season! Start 2021 by learning SQL and data engineering. In this article, we answer frequently asked questions about our Creating Database Structure track. Maybe you haven't noticed yet that there’s an order to many LearnSQL.com courses; you can learn SQL by doing them in the right order. We call this option our ‘SQL tracks’. These are logically structured and well-thought-out learning paths that will help you take the next steps towards becoming an SQL expert.

What is an SQL View?

A view is a well-known feature in SQL. It allows you to create a virtual table based on an SQL query referring to other tables in the database. A view stores an SQL query that is executed whenever you refer to the view. This is a convenient way to get the desired data because it is easier to run a query stored in a view than to type a query from scratch.

What Is a Foreign Key in SQL?

What does a foreign key do in SQL? Why would you need one? Learn the ABCs of foreign keys in five minutes. Foreign keys are a central concept in SQL databases; they allow us to enforce data consistency. Usually they work with primary keys to connect two database tables, like a virtual bridge. All SQL developers need to know what SQL foreign keys are, how they work, what data values are allowed in them, and how they’re created.

What Is a SQL Constraint?

What are SQL constraints? When and why should you use them? We give examples of common constraints and demonstrate how to apply them. When you’re creating a relational database, you often want to impose certain restrictions on some columns. For example, a column containing a social security number should store only unique values; a column containing a date of birth should not be null, or left empty. These conditions can be ensured by using SQL constraints.

Top 7 Online Courses for Data Engineers

This article summarizes the top online courses available for data engineers. We have picks suitable for beginners as well as intermediate learners. If you’re interested in database design and management, check these courses out! Most individuals who aspire to enter the realm of data aim for data scientist or data analyst roles. While these roles are indeed very rewarding because of their tangible links to customers and business direction, the role of data engineers is equally vital for businesses that operate in a data-rich environment.

What is a Primary Key in SQL?

Primary keys are an important concept in SQL databases. They provide a unique ID for every row in a database table. As an SQL developer, you should know what primary keys are, what data values are allowed in them, and how to create them. Read this article to learn the ABCs of primary keys in 10 minutes. How to Identify Rows in a Table Tables are the main objects in an SQL database, and as you probably know, tables store records or rows.

What Is a DBMS?

Updated on: February 19, 2024 We generate vast quantities of data every day, and that data needs to be stored somehow. That’s where DBMSs come in handy. Find out what they are and how they relate to databases. If you go on a diet and simply want to keep track of your weight, you can probably use a piece of paper and a pencil. If you then want to chart your daily caloric intake, you’ll probably switch to something like a computer spreadsheet.

How to Create Your First Table in SQL

Creating a database table with SQL is one of the core skills you’ll need to work with data. And it’s easy to learn, so let’s get started! Imagine you’re analyzing data and want to store your results in a database table. Sure, you've done this a million times in Excel. But you’re not sure how to create a table with SQL. Or maybe you’ve noticed that data engineering is in high demand and you want to start learning its core concepts.

How Much Do Data Engineers Earn in 2020?

Data engineering is a hot job right now. What does a data engineer do? And just how much do they earn? We’ve done the research for you. If you are reading this, you’re either starting to learn SQL or you already know some and feel it’s time to look around for a SQL job. Maybe you’re in the midst of tackling our Creating Database Structure track. And, let’s be honest, maybe you need some extra motivation to keep on you track.

How to Create a Table in SQL

Creating tables in databases is a very helpful skill, and not just for software engineers or database administrators. It allows you to design or change the structure of a database and store data that’s related to each other. In this article, you’ll learn what a database table is, who creates them, and how to use the syntax of the CREATE TABLE command. What Is a Database Table? A relational database is built of various structures like tables, views, procedures, and triggers.

Who Is a Data Engineer?

A new kind of job has recently emerged in the IT world: Data Engineer. At first sight, it may seem very similar to Data Analyst or Data Scientist positions. However, our article explains all the important differences. We present the skills, tools, and everyday tasks of Data Engineers. We also explain how you can get started with this career path.   Thirty years ago, we typically used terms such as “Computer Scientist” when referring to anyone working with computers.

LearnSQL.com’s New Learning Path: Data Engineering

Calling all future data engineers! Would you like to learn to use SQL? Then our new Data Engineering Learning Path is just for you! We’re very excited to announce the release of a new learning path at LearnSQL.com: Data Engineering, published in July 2020. This is the second learning path offered in our platform. So far, we offered an analytical path, SQL Querying & Reporting, that focuses on writing queries and business reports in SQL.

What Is Data Engineering?

Data Engineering is a fairly new term in IT. And it’s getting more and more attention. You may have heard about a few similar fields like data science, Big Data, and machine learning. This article explains the difference between these concepts and shows how they can be combined to analyze vast amounts of data. When computers first appeared, their storage capacity was very limited. Do you remember floppy disks? They were popular in the late 20th century and typically offered around 1.

Comparing TRUNCATE TABLE, DELETE, and DROP TABLE in SQL

What’s the difference between truncating, deleting, and dropping a table in SQL? Find out in this article. There are a lot of ways to delete data in SQL, including the DELETE, TRUNCATE TABLE and DROP TABLE commands. Which one should you use in a given situation? In this article, you’ll learn the syntax of each command in different database engines like MySQL, PostgreSQL, SQL Server, and Oracle. And you’ll understand the DROP TABLE vs.

Tag: Data Modifying

Simplify SQL Code: Recursive Queries in DBMS

Hey SQL users! Are you repeating the same query in every report? Are your queries getting too complicated? Use recursive queries to simplify SQL code! Too many SQL reports can lead to clutter on your desktop and in your head. And is it really necessary to code each of them separately? Ad-hoc queries can share much of the same SQL code with managerial reports and even regulatory reports. Suppose you’ve been writing basic SQL code for a while.

Using CASE with Data Modifying Statements

What happens when you combine CASE with SQL's data modifying statements? Find out in this article. The CASE expression is a very useful part of SQL and one that you'll employ frequently. We've already covered what the CASE expression does, how to format it, and how to use it in a SELECT statement in "Using CASE to Add Logic to a SELECT". Another article, "How to Sort Records with the ORDER BY Clause"

Tag: Data Quality

Extracting Data From a String: SPLIT_PART in PostgreSQL

Learn how to use split_part in PostgreSQL to extract data from strings. Quite often, we’d like to extract parts of a string when working with text values. A common example is when we have a full name and need to retrieve only the last name. In this article, we’ll examine how to do it using split_part in PostgreSQL, i.e. a string-related function that can be used to extract a substring.

How to Remove Junk Characters in SQL

Unwanted characters in text data can be a bit of a pain, but there’s an easy way to fix them. Scroll down to learn how to remove junk characters in SQL in the easiest way! Sometimes, we’ll find unwanted characters inside our string data because our SQL queries didn’t work as expected. Moreover, these extra characters may sometimes be invisible, which really complicates things. In this article, we’ll examine some string-related SQL functions that can handle unwanted characters—visible or not!

How to Solve Capitalization Data Quality Issues

Misspelled names, typos, and text data quality issues in your database? Power up your queries! Use SQL string functions to address data quality issues related to capitalization. Sometimes, our SQL queries don't work as expected because of data quality issues. In this article, we will examine some string-related SQL functions that can correct data quality issues related to capitalization. We'll be using PostgreSQL in our examples, but similar functions are available in most database engines.

Tag: Data Science

Learn SQL for Data Science With LearnSQL.com

If you are interested in a data science career and have looked at a few relevant job descriptions, you've probably noticed many leading tech companies expect their data scientists to know SQL. Let's see how you can learn SQL for data science and become more valuable to any data-driven organization. A data scientist is a complex technical role that expects a combination of the skills of a statistician, a business analyst, and an IT expert.

Tag: Data Types

Understanding Numerical Data Types in SQL

Working with databases of any kind means working with data. This data can take a couple of predefined formats. As you start on your learning path with LearnSQL.com, you will start to understand SQL's different data types. In this article, we will cover different variations of the SQL numeric data type. We'll also examine some functions that convert data from one type to another. Creating tables is the first step in any SQL coding project.

How to Recognize SQL Text Data Type

How can you store textual information in database tables? Thanks to this post, you’ll learn the characteristics of every text data type in SQL Note: This post is intended for readers familiar with SQL data definition language (DDL) and the DDL CREATE statement. To learn more about DDL, check out LearnSQL.com. Most data types are classified as NUMERIC, CHARACTER, or DATE. In this post, we’re going to focus on each CHARACTER or text data type in SQL.

Tag: Data Warehouse

How to Join Tables in SQL Without Using JOINs

Here’s how you can combine tables without the JOIN keyword. It seems like it shouldn’t be possible: join tables in SQL without using the JOIN keyword. But using the JOIN keyword is not the only way to join tables in SQL. This article will show you two additional methods for joining tables. Neither of them requires the JOIN keyword to work. They are: Using a comma between the table names in the FROM clause and specifying the joining condition in a WHERE Using UNION/UNION ALL.

Tag: Database

The Most Popular Databases in 2024

Updated on: April 6, 2024 If you work with data – or if you want to start – you need a database that will answer your needs. Not sure what to choose? Don’t worry! In this article, you’ll find a list of today’s most popular and efficient databases, with a quick summary of what each one does. Businesses run on data. But to get the most from that data, it needs to be stored in a structured way – usually in a database.

What Is an SQL Database?

SQL databases have been used for decades and have grown in popularity, becoming one of the most common data management tools. They provide the user with an efficient way to store the data and an intuitive way to access or modify it. In this article, we’ll start by explaining what a database is and showing some examples. We’ll move on to how databases can be used to efficiently work with large amounts of structured data.

The Most Popular Databases for 2022

With the number of database products increasing with each passing year, it is important to understand which database best fits your use case. This article lists the top-ranking databases available in the market today. When something that first became popular in the early 1980s is not slowly fading away but is still evolving and becoming more relevant, you know it had to be an important invention. The database is no exception.

Tag: Database Collations

Oracle Collations: Binary and Linguistic Collations

Oracle bases its language support on the values of parameters that begin with NLS. These parameters specify, for example, how to display currency or how the name of a day is spelled. The table below presents some of the NLS parameters. By using one of them, NLS_SORT, we can specify the sort method (binary or linguistic) for both SQL WHERE clause operations and NLSSORT function operations. Option Name Description NLS_LANG The current language, territory, and database character set, which are determined by session-wide globalization parameters.

PostgreSQL Collations

List Collations Collations in PostgreSQL are available depending on operating system support. For example, in Ubuntu type the following to list the names of the available collations: locale -a The same locales are available in PostgreSQL in the pg_collation catalog (mappings from an SQL name to operating system locale categories). select * from pg_collation; collname | collnamespace | collowner | collencoding | collcollate | collctype -----------+---------------+-----------+--------------+-------------+------------ default | 11 | 10 | -1 | | C | 11 | 10 | -1 | C | C POSIX | 11 | 10 | -1 | POSIX | POSIX C.

MySQL Collations

List Collations To list all collations available in MySQL, use SHOW COLLATION; +-------------------+----------+-----+---------+----------+---------+ | Collation | Charset | Id | Default | Compiled | Sortlen | +-------------------+----------+-----+---------+----------+---------+ | big5_chinese_ci | big5 | 1 | Yes | Yes | 1 | | big5_bin | big5 | 84 | | Yes | 1 | | dec8_swedish_ci | dec8 | 3 | Yes | Yes | 1 | | dec8_bin | dec8 | 69 | | Yes | 1 | | cp850_general_ci | cp850 | 4 | Yes | Yes | 1 | | cp850_bin | cp850 | 80 | | Yes | 1 | | hp8_english_ci | hp8 | 6 | Yes | Yes | 1 | | hp8_bin | hp8 | 72 | | Yes | 1 | | koi8r_general_ci | koi8r | 7 | Yes | Yes | 1 | | koi8r_bin | koi8r | 74 | | Yes | 1 | | latin1_german1_ci | latin1 | 5 | | Yes | 1 | | latin1_swedish_ci | latin1 | 8 | Yes | Yes | 1 | | latin1_danish_ci | latin1 | 15 | | Yes | 1 | | latin1_german2_ci | latin1 | 31 | | Yes | 2 | | latin1_bin | latin1 | 47 | | Yes | 1 | | latin1_general_ci | latin1 | 48 | | Yes | 1 | .

How Does a Database Sort Strings?

Different languages have different alphabets and different ways to order letters within those alphabets. For example, a Polish character Ł comes right after L and before M. In Swedish, a letter Å comes almost at the end, right after Z. In French diacritics marks have no impact on the alphabetical order, so the letters À, Á and  are treated as the letter A when sorting strings. A collation is a set of rules that defines how to compare and sort character strings.

Tag: Date

Basic Date and Time Functions in MS SQL Server

As a follow up to our article “The Most Useful Date and Time Functions in Oracle Database”, let’s review what date and time functions look like in MS SQL Server. Let’s start with functions that extract a year, month and day from a given date. declare @dt date = '2014-10-20' select year (@dt) as year, month (@dt) as month, day (@dt) as day SQL Server uses GETDATE() and SYSDATETIME() to get a current date and time.

Tag: Date and Time

Useful SQL Patterns: Date Generator

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. SQL patterns, such as the pivot pattern we discussed last week, can save you a lot of time and effort. Suppose you are asked to get a range of days in a financial quarter, but the only records you have are for the start and end dates of each quarter.

Performing Calculations on Date- and Time-Related Values

Relational databases support several date and time data types. In this article, we'll look at several arithmetic operations we can do on these types. These operations are logical and understandable, even for the beginning SQL coder. Let's first briefly explain the main data types used for dates and times. Keep in mind that data types may differ by database engine, so check your database documentation for specifics before you start working with them.

The Most Useful Date and Time Functions

Date and time functions and formats are quite different in various databases. In this article, let's review the most common functions that manipulates dates in an Oracle database. The function SYSDATE() returns a 7 byte binary data element whose bytes represents: century, year, month, day, hour, minute, second It's important to know that select sysdate from dual in SQL*Plus gives the same result as select to_char(sysdate) from dual because SQL*Plus binds everything into character strings so it can print it.

Tag: Date Arithmetic

The SQL Coalesce Function: Handling Null Values

You may already know how to return null values in SQL. Now, we’re going to learn how to do the opposite. Though the SQL COALESCE function may seem complex, it’s actually very straightforward and useful. Let’s look at several examples of how the SQL COALESCE function can be used to work with NULL values in SQL. The Need for Coalesce in SQL Before we dive into the SQL COALESCE function in detail, you should understand how NULL values behave in expressions.

SQL Date and Interval Arithmetic: Employee Lateness

Computing Tardiness: Date, Time, and Interval SQL Arithmetic In this article, we’re going to discuss some interesting operations we can perform with date-related data types in SQL. The SQL standard, which most relational databases comply with these days, specifies the date-related data types that must be present in relational databases. The most important of such data types are date, time, timestamp, and interval. Here’s a brief rundown of the differences between these data types:

Tag: Date Functions

MySQL Date Functions: Complete Analyst’s Guide

Master MySQL date functions and acquire a powerful tool to work with date and time information in your data analyses. Working with date and time data is an essential part of data analysis. Here are just three examples: Analyzing historical time series data is crucial for discovering trends and making reliable forecasts based on chronological information. Stock market analysis examines time series data extensively, especially when automated trading algorithms are employed.

SQL Server Date Functions: A Data Analysis Guide

Date functions are the bread and butter of data analysis and reporting with SQL Server. In this guide, I will show you practical examples of the use of SQL Server date functions and how to apply them to your reports. A question for all data analysts: Do you want to be taken seriously? I’m sure you do. In that case, knowing SQL Server date functions is mandatory. Date and time data types are ubiquitous in databases, as they are essential for reporting.

18 Useful Important SQL Functions to Learn ASAP

Updated on: October 30th, 2023 Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike.

Tag: Dcl

What Are DDL, DML, DQL, and DCL in SQL?

We explore the separation of SQL into its four principal sublanguages and explain the meaning behind each of them. When you’re learning SQL – perhaps through LearnSQL.com’s very own comprehensive SQL Basics course – you may have come across the terms DDL, DML, DQL, and DCL. And maybe you’ve gotten confused by all the acronyms. In this article, we will explain what these terms stand for and how they correspond to sublanguages that neatly divide the SQL language into four parts that function together.

Tag: Ddl

What Are DDL, DML, DQL, and DCL in SQL?

We explore the separation of SQL into its four principal sublanguages and explain the meaning behind each of them. When you’re learning SQL – perhaps through LearnSQL.com’s very own comprehensive SQL Basics course – you may have come across the terms DDL, DML, DQL, and DCL. And maybe you’ve gotten confused by all the acronyms. In this article, we will explain what these terms stand for and how they correspond to sublanguages that neatly divide the SQL language into four parts that function together.

Tag: Delete

What Is the DELETE Statement in SQL?

This article will explain the use of the DELETE statement, one of the primary methods of removing existing records from your database. First we will run through the syntax, followed by some easy-to-understand examples. The DELETE statement in SQL is extremely useful. It allows you to remove any obsolete or “bad” data from your database tables. You should exercise caution when using the DELETE statement, as the operation is not reversible.

Learn SQL Views in 30 Minutes

Views aren't complicated – if you've got half an hour, we'll get you started writing SQL queries using views! Let's start by answering the question "What is a view in SQL?'. A view is a database object (as is a table, an index, or a stored procedure). Like a table, you can query a view and extract the information in it. It can be used in the FROM clause of a SELECT, and you can reference view columns in clauses like SELECT, WHERE and GROUP BY among other clauses as well.

Using CASE with Data Modifying Statements

What happens when you combine CASE with SQL's data modifying statements? Find out in this article. The CASE expression is a very useful part of SQL and one that you'll employ frequently. We've already covered what the CASE expression does, how to format it, and how to use it in a SELECT statement in "Using CASE to Add Logic to a SELECT". Another article, "How to Sort Records with the ORDER BY Clause"

Tag: Distinct

What’s the Difference Between UNIQUE and DISTINCT in SQL?

We use the words unique and distinct interchangeably in our day-to-day life. However, these words play very different roles in SQL. Let’s find out what is so different about them and how we can use them in SQL. Despite the words unique and distinct being synonyms, they cover very different things in SQL. The UNIQUE keyword in SQL plays the role of a database constraint; it ensures there are no duplicate values stored in a particular column or a set of columns.

What Is the Role of DISTINCT in SQL?

The DISTINCT keyword in SQL plays an important role in removing duplicate values from your results. This article provides examples showing exactly how DISTINCT works. By default, SQL queries show all the returned rows, including duplicate rows, in the result set. The DISTINCT keyword in the SELECT clause is used to eliminate duplicate rows and display a unique list of values. In other words, the DISTINCT keyword retrieves unique values from a table.

Tag: Division

How the Division Operator Works in SQL

The division operator in SQL is used to divide one expression or number by another. This article will show you exactly how to use it and common mistakes to avoid along the way. The best way to practice SQL is our interactive SQL Practice track. It contains over 600 hands-on exercises that conver varios SQL topics, from simple one-table queries, through JOINs, to complex topics like subqueries. It lets you train your SQL skills on real business examples.

Tag: Dml

What Are DDL, DML, DQL, and DCL in SQL?

We explore the separation of SQL into its four principal sublanguages and explain the meaning behind each of them. When you’re learning SQL – perhaps through LearnSQL.com’s very own comprehensive SQL Basics course – you may have come across the terms DDL, DML, DQL, and DCL. And maybe you’ve gotten confused by all the acronyms. In this article, we will explain what these terms stand for and how they correspond to sublanguages that neatly divide the SQL language into four parts that function together.

Tag: Dql

What Are DDL, DML, DQL, and DCL in SQL?

We explore the separation of SQL into its four principal sublanguages and explain the meaning behind each of them. When you’re learning SQL – perhaps through LearnSQL.com’s very own comprehensive SQL Basics course – you may have come across the terms DDL, DML, DQL, and DCL. And maybe you’ve gotten confused by all the acronyms. In this article, we will explain what these terms stand for and how they correspond to sublanguages that neatly divide the SQL language into four parts that function together.

Tag: Duplication

How to Track Down Duplicate Values in a Table

When it comes to information management, duplicates present one of the most common challenges to data quality. In this article, I'll explain how it is possible to find and distinguish duplicate names with the help of the SQL data programming language. I really like my maiden name. The reason I like it so much is because it's rare. My maiden name (first with last) provided a unique identifier on platforms such as LinkedIn, Facebook, Twitter and similar.

Tag: E Learning

New Feature: Notebook to Boost Your SQL Learning

You want to learn SQL effectively but you keep forgetting queries? Now you can use  LearnSQL.com’s new notebook feature in all our courses! This new tool will help you memorize and recall content. I remember when I first started to learn SQL. I was moving quite smoothly through most of the lessons, taking a lot of notes in my paper notebook. (I have a lot of old school paper notebooks).

Top 5 Beginner Online SQL Courses in 2020

Looking for an exciting new career? Data analysis won’t disappoint you! The simplest way to make this possible is by learning SQL, and online SQL courses are the most effective learning method. Don’t know where to start? Here’s an overview of the best online SQL courses for complete beginners. There are infinite reasons for changing your industry. You may want to land a new job because you’re burnt out. You may be bored and want something more challenging.

Choose the Best Way to Learn SQL

SQL has become a hot topic in the professional world, and many resources have appeared both online and offline for learning SQL. It’s easy to get lost in the jungle of books, tutorials, and courses. Which resources do you choose? If you want to know how to learn SQL quickly and effectively, take a look at my list. There are many reasons for learning SQL. We asked our users about them and learned that there was no universal motive.

Stay at Home and Learn SQL for Free with LearnSQL.com

Working remotely is a dream come true for some. You ditch commuting and have more time for the people you love and the things you enjoy. For others, it's a challenge to maintain their focus when there are new distractions. It's also an opportunity to invest the few gained hours in learning something new. Staying at home can be a time when you might find yourself busier than you've ever been, but not getting many things done, and worse, not learning what you planned to.

What Programming Language Should You Learn?

If you've ever been wondering which programming language you should learn first, you know that's a tough nut to crack. It’s especially difficult if you are new to IT and programming. In this article, I give suggestions for what to learn first and what perspectives each language can give you in IT. There are hundreds of programming languages, and new ones are showing up all the time. Getting to know all of them is simply impractical and impossible.

How to Study Online: 5 Steps to Effective Learning

If you suffer from procrastination or lack of motivation, you’re not alone. We have some online learning tips to make your learning journey smoother and more enjoyable. One of the best things about being an adult is that we can do what we want: go to sleep late at night, party until morning, eat junk food. Besides all those small pleasures, as adults we are responsible for ourselves, our choices, and our mistakes.

Tag: Edgar Codd

53 Years of Relational Databases

If it weren't for him, there would be no modern databases. It is the 53st anniversary of the publication of his article that changed the rules of the game. Edgar Frank Codd is one of the fathers of SQL, and his name is one of the first to be mentioned in the history of databases. Or maybe even the history of computer development in general? See what we owe to Dr.

Tag: Elearning

Learn SQL on Your Lunch Break

Do you think learning SQL will help you in your career? You are right. SQL is one of the easiest computer languages to learn. These days many non-IT employees have SQL skills and use them to extend their professional capacity. Moreover, more and more companies are encouraging their employees in non-IT areas (like sales, advertising, and finances) to learn and use SQL. One of the benefits of empowering employees with SQL skills is that once you answer one data question, the results will generate a new data question, and then perhaps a cascade of further data questions.

5 Reasons Why No One Should Be Afraid to Learn SQL

Updated on: September 17, 2023 Think SQL is just for tech experts? Think again. In this article, we'll bust some common myths and show you that anyone can learn SQL. Let's dive in and make SQL simple. In today’s world, even those in non-technical jobs need some technical skills. And you don’t have to be a hard-core nerd to get these skills. Everywhere you look, from marketing to management, a touch of tech knowledge can set you apart.

How to Learn SQL: 6 Ideas for Newbies

Learning a new skill can be a daunting task, especially in programming. SQL is not immune to this. Luckily, with the Internet and the explosion of programming-related information out there, there are a lot of options you can use to undergo your SQL training! But we then come to a new roadblock. Where to begin? How will we know which option is best for our budget, skill level, and schedule?

Tag: Extras

SQL INSERT, SQL UPDATE, SQL DELETE – Oh My!

Need to understand SQL INSERT, UPDATE, or DELETE? We'll get you up to speed with a comprehensive How-To and useful examples! SQL INSERT, UPDATE, and DELETE statements—what are they all about? If you're a data engineer, a database administrator, or even just your average data fanboy or girl, one day you're going to find yourself with a database that becomes your "baby." Charged with this special bundle of joy, you're going to need to feed and change the little fella.

SQL, Databases, and Hollywood Movies

Policemen, doctors, lawyers, scientists, teachers: These are the professions that we often see in Hollywood movies. But are movies also trying to show what the work of data analysts looks like? Here is a list of six movies in which screenwriters, directors, and producers decided to cast SQL and databases in the main roles. Data analysis is most often associated with business, reporting, and making key decisions for the company.

Career Change: From Accountant to Database Designer

How do career changes and life choices impact our future? Can we change the path that's been set for us? And if so, where do we begin? I wouldn't blame you if you thought this article is about change. In a sense, it is—it's in the title, after all. But for me, this article is more about what remains constant. If somebody were to ask me what hasn't changed for me since my childhood, I would know the answer immediately: curiosity.

Forget About Excel, High Five With SQL

Find out why you should forget about Excel and start using SQL even if you're not an IT expert. We'll show you how easy it is to learn SQL, how it can make you work better, and how LearnSQL.com makes the learning process fun. "I Don't Deal With Data" We frequently hear the sentence above from people outside the IT industry. Well, it's not entirely true. Data is now almost everywhere.

How to Install PostgreSQL on Windows 10 in 5 Minutes

It may look like a complicated task to install PostgreSQL, Oracle, or SQL Server or any other database software, but it really isn’t! These days, most relational database management systems come with installation wizards that make the process much simpler. In this article, we’ll look at how to install PostgreSQL and test that the installation is working. Install PostgreSQL: Steps Involved To install PostgreSQL, we’ll complete the following tasks:

Our Picks for 2020’s 7 Best Online SQL Schools

If you’re looking for the best online SQL courses but aren’t sure where to start, you’re in the right place. I evaluated the top 7 ranked SQL schools available online to help you find the right solution. While summer is a great time to relax and get away from work, it’s also an excellent opportunity to learn new skills – like SQL! Thanks to SQL schools putting their courses on the internet, learning new tech skills is super easy and you can choose from a variety of formats to suit your needs.

Why Learn SQL Over the Summer

Think summer is reserved for flying to warm places and hanging out at the beach? Sure! But it's also a great time to learn new skills that you haven't had time for. If you recently graduated from high school and want to get a head start on computer programming for college, learning SQL over the summer is a great opportunity. You have nothing to lose and everything to gain—SQL is actually really easy to learn, especially with so much free time over the summer.

Essential SQL Terms to Know for Beginners and Pros

Updated on: April 11, 2024 Working with databases can seem daunting to a non-technical person. Right away, you’re bombarded with new terms that make your head spin. Database, database instance, table, SQL and others are some of the basic terms that you need to understand just to have a normal conversation with your technical colleagues. In this article, we’ll explore some basic SQL database terminology you need to know to succeed.

How to Draw a Christmas Tree in SQL

You can use SQL to manipulate all kinds of data, from huge analytical queries to brief single-purpose statements. But you can also use SQL just for fun, without any business requirements stifling your creativity. So, get out your jolly hat and prepare to sing O Christmas Tree as we create some quirky art with plain old SQL. Today, we’re going to generate some holiday-themed ASCII art, just for fun. That’s right.

SQL Hacks To Control Family Budget On Black Friday Weekend

If you’re in the US, chances are you’ve been eagerly awaiting the approach of Black Friday just as much as Thanksgiving. Though the shopping frenzy takes hold of nearly everyone, some people have to stick to their budgets and shop prudently. In this article, we’ll take a look at how generating an SQL report can help you track how much your family spent shopping on Black Friday. Storing Black Friday Purchases in a Database Before we can create an SQL report, we first need some data we can use.

The 5 Highest Paying Jobs That Use SQL

IT provides a wide and growing job market, offering many excellent opportunities in both career development and earning potential. Today we’ll take a look at several very interesting types of database jobs that use SQL. Every year, many in the work force set their sights and aim for new and better jobs. When it comes to jobs, “better” means different things to different people, but earning potential is almost always a top priority.

5 Reasons Why No One Should Be Afraid to Learn SQL

Updated on: September 17, 2023 Think SQL is just for tech experts? Think again. In this article, we'll bust some common myths and show you that anyone can learn SQL. Let's dive in and make SQL simple. In today’s world, even those in non-technical jobs need some technical skills. And you don’t have to be a hard-core nerd to get these skills. Everywhere you look, from marketing to management, a touch of tech knowledge can set you apart.

5 Books That Will Grow Your SQL Skills

Updated on: April 18, 2024 Looking to take your database skills up a notch? I've spent some time digging into various resources, and I want to share five advanced SQL books that really stood out. These texts are not just about learning the basics: they're about mastering the intricacies of SQL and truly enhancing your database management prowess. Whether you're troubleshooting complex queries or optimizing performance, these books provide insights that are both practical and transformative.

Tag: Fact Table

How to Join Tables in SQL Without Using JOINs

Here’s how you can combine tables without the JOIN keyword. It seems like it shouldn’t be possible: join tables in SQL without using the JOIN keyword. But using the JOIN keyword is not the only way to join tables in SQL. This article will show you two additional methods for joining tables. Neither of them requires the JOIN keyword to work. They are: Using a comma between the table names in the FROM clause and specifying the joining condition in a WHERE Using UNION/UNION ALL.

Tag: Fetch

Oracle Top-N Queries for Absolute Beginners

It's common to run a query using only part of a dataset – for example, the top 100 salespeople in a company. In this article, we'll see how to use Oracle's Top-N query method to query just these rows. Top-N queries retrieve a defined number of rows (top or bottom) from a result set. In other words, they find the best or worst of something – the ten best selling cars in a certain region, the five most popular routers, the 20 worst-performing stores, etc.

Tag: Foreign Key

What Is the Benefit of Foreign Keys in SQL?

What is a foreign key and why is it so important in relational databases? Learn all the details about foreign keys in this article. One of relational databases’ key features is the ability to link data stored in different tables. These links, called references, essentially act as connections between tables. They are created using the FOREIGN KEY constraint on table columns. In this article, we’ll learn what the FOREIGN KEY constraint does in SQL.

Referential Constraints and Foreign Keys in MySQL

Foreign keys and referential constraints allow you to set relationships between tables and modify some of the database engine’s actions. This beginner’s guide explains referential integrity and foreign key use in MySQL. One of the most important aspects of database usage is being able to trust the information you store. Database engines provide several features that help you maintain the quality of your data, like defining required columns as NOT NULL and setting an exact data type for each column.

Tag: Free Sql Course

Free SQL Courses to Elevate Your Skills

In this article, I'll explain why LearnSQL.com offers free SQL courses. I’ll also introduce you to some of the courses we’ve offered for free over the years. If you're eager to enhance your SQL skills without breaking the bank, you've come to the right place. You're here because you understand the significance of learning SQL. But are you tired of those lengthy YouTube tutorials? How about diving into an online SQL course?

Stay at Home and Learn SQL for Free with LearnSQL.com

Working remotely is a dream come true for some. You ditch commuting and have more time for the people you love and the things you enjoy. For others, it's a challenge to maintain their focus when there are new distractions. It's also an opportunity to invest the few gained hours in learning something new. Staying at home can be a time when you might find yourself busier than you've ever been, but not getting many things done, and worse, not learning what you planned to.

Tag: Functions for Manipulating Sql Strings

A Complete Guide to Working With Substrings in SQL

In this article, we’ll discuss how to work with substrings in SQL. It involves learning several approaches, so we’ll show you their ins and outs. To work with substrings in SQL, we first need to know what a string is. In programming, a string is any kind of textual data (a title, a description, a name). A string consists of any number and type of characters. In a SQL database, strings are typically stored as CHAR or VARCHAR data types.

5 SQL Functions for Manipulating Strings

SQL functions used for manipulating strings, commonly called string functions, are among most important SQL’s tools. In this post, we’ll look at five ways you can perform various operations on strings. There are many SQL functions that let you “edit” string data. As you learn SQL, you’ll see how useful they prove. Some sql trim off unneeded spaces or characters; others tell you how long a string is. These functions give you a lot of opportunities to transform and work with strings, which makes your code more effective.

Tag: Generators

Useful SQL Patterns: Date Generator

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. SQL patterns, such as the pivot pattern we discussed last week, can save you a lot of time and effort. Suppose you are asked to get a range of days in a financial quarter, but the only records you have are for the start and end dates of each quarter.

Tag: Get Started

How to Install MS SQL Server 2019 on Windows

Do you want to install SQL Server 2019 on your Windows PC? How about the latest version of SQL Server Management Studio? I’ll walk you through the process. Soon you’ll be writing T-SQL queries and operating on SQL Server databases! As I write this article, Microsoft SQL Server 2019 is the latest version of SQL Server. It’s the 15th version of one of the most popular database servers in the world.

Join us on Facebook–We Can Learn More Together

We are so happy that you have joined us to learn and develop your SQL skills! We want to invite you to a new Facebook group, We Learn SQL. It is a great place for anyone interested in meeting like-minded people who also want to learn about database-related concepts. Learning together is easier, don't you think? Joining this group is a great opportunity to begin sharing your learning experiences with others.

YouTube Tutorials That Actually Teach You Some SQL

YouTube is not just funny cats, music clips, and viral videos. It can also be a mine of knowledge – if you know where to look. Can YouTube tutorials really help you learn SQL? Let's say you're a marketer or an accountant. You work with databases every day. But when it’s time to write a query and get specific data, you need to call someone from IT. Why not learn to do it yourself?

Career Change: From Accountant to Database Designer

How do career changes and life choices impact our future? Can we change the path that's been set for us? And if so, where do we begin? I wouldn't blame you if you thought this article is about change. In a sense, it is—it's in the title, after all. But for me, this article is more about what remains constant. If somebody were to ask me what hasn't changed for me since my childhood, I would know the answer immediately: curiosity.

Forget About Excel, High Five With SQL

Find out why you should forget about Excel and start using SQL even if you're not an IT expert. We'll show you how easy it is to learn SQL, how it can make you work better, and how LearnSQL.com makes the learning process fun. "I Don't Deal With Data" We frequently hear the sentence above from people outside the IT industry. Well, it's not entirely true. Data is now almost everywhere.

Learn SQL on Your Lunch Break

Do you think learning SQL will help you in your career? You are right. SQL is one of the easiest computer languages to learn. These days many non-IT employees have SQL skills and use them to extend their professional capacity. Moreover, more and more companies are encouraging their employees in non-IT areas (like sales, advertising, and finances) to learn and use SQL. One of the benefits of empowering employees with SQL skills is that once you answer one data question, the results will generate a new data question, and then perhaps a cascade of further data questions.

How to Install PostgreSQL on Windows 10 in 5 Minutes

It may look like a complicated task to install PostgreSQL, Oracle, or SQL Server or any other database software, but it really isn’t! These days, most relational database management systems come with installation wizards that make the process much simpler. In this article, we’ll look at how to install PostgreSQL and test that the installation is working. Install PostgreSQL: Steps Involved To install PostgreSQL, we’ll complete the following tasks:

How SQL supports data-driven organization

Typical business users make decisions based on gut feelings, but this can't get them so far. In this article, we'll look at how learning to write basic SQL queries helps your company become a data-driven organization. Businesses face many decisions. Do we increase our advertising budget in one region or the other? Are certain products selling quickly enough? What we should do if they aren't? Most of these decisions are driven by intuition, but organizations that make the most business impact use data-driven decision-making.

Microsoft SQL Server 2017 Installation Step by Step

Microsoft SQL Server is one of the most popular professional database servers on the market. In this guide, I’ll show you all SQL Server 2017 installation steps to help you install it on the Windows operating system together with SQL Management Studio. If you want to learn T-SQL, the dialect of SQL used in SQL Server, check out our SQL from A to Z in MS SQL Server track.

How to Begin Running SQL Queries

In this article, I’ll explain how to run a SQL query to help you execute your first one. Let’s jump right in! Running SQL queries for the first time is not a complex task, but it can seem intimidating at first if you’re a complete beginner. But once you get past that initial roadblock, you’ll be able to focus on learning SQL and writing more interesting queries to meet your business needs.

How to Use a SQL Wildcard

SQL wildcard allows us to filter data matching certain patterns in SQL. We use SQL wildcards with the LIKE operator in the WHERE clause of a query to filter data. In this beginner’s article, we’ll look at everything you need to know about basic SQL wildcards. If you like playing cards, then you know that wildcards can substitute any other card in your deck. Similarly, SQL wildcards can substitute one or more characters.

Our Picks for 2020’s 7 Best Online SQL Schools

If you’re looking for the best online SQL courses but aren’t sure where to start, you’re in the right place. I evaluated the top 7 ranked SQL schools available online to help you find the right solution. While summer is a great time to relax and get away from work, it’s also an excellent opportunity to learn new skills – like SQL! Thanks to SQL schools putting their courses on the internet, learning new tech skills is super easy and you can choose from a variety of formats to suit your needs.

Why Learn SQL Over the Summer

Think summer is reserved for flying to warm places and hanging out at the beach? Sure! But it's also a great time to learn new skills that you haven't had time for. If you recently graduated from high school and want to get a head start on computer programming for college, learning SQL over the summer is a great opportunity. You have nothing to lose and everything to gain—SQL is actually really easy to learn, especially with so much free time over the summer.

How to Start Thinking in SQL

Thinking in SQL will help you understand what SQL queries do, how to create and change them, and how to create reports from the data you obtain. If you want to know how to write better SQL queries, you have to change the way you think about the code. One of the greatest skills you can have in SQL programming is the ability to change an existing SQL query so you get the results you need.

SQL Reporting Guide for Business Professionals

Working with the financial aspects of large and small enterprises can be a daunting task for a business professional. In this article, we'll look at several ways of constructing the perfect SQL report. You've probably already heard about SQL from your colleagues or in other areas of your career. If you're here, you've likely concluded that learning SQL will make your professional life easier – and you're right!

5 Great Benefits of Learning SQL

If you want your business to succeed in 2017, it’s absolutely critical that you understand your data; this is why you should get acquainted with SQL ASAP. But there are other reasons to learn it that may not be obvious. In this article, I’ll show you 5 huge benefits of learning SQL! Don’t fall for the common trap—analyzing data isn’t just a concern for those competing at national or corporate levels.

5 Reasons Why No One Should Be Afraid to Learn SQL

Updated on: September 17, 2023 Think SQL is just for tech experts? Think again. In this article, we'll bust some common myths and show you that anyone can learn SQL. Let's dive in and make SQL simple. In today’s world, even those in non-technical jobs need some technical skills. And you don’t have to be a hard-core nerd to get these skills. Everywhere you look, from marketing to management, a touch of tech knowledge can set you apart.

5 Books That Will Grow Your SQL Skills

Updated on: April 18, 2024 Looking to take your database skills up a notch? I've spent some time digging into various resources, and I want to share five advanced SQL books that really stood out. These texts are not just about learning the basics: they're about mastering the intricacies of SQL and truly enhancing your database management prowess. Whether you're troubleshooting complex queries or optimizing performance, these books provide insights that are both practical and transformative.

The Complete Beginner’s Guide to SQL Fundamentals

LearnSQL.com is a great place to learn SQL. If you’re a complete beginner, it’s best to have an overview of what SQL is, what a database is, and how they work together. In this article, you’ll find a complete guide to SQL fundamentals. SQL Fundamentals: Database Let’s begin our guide to SQL with basic definitions. You might have already heard that SQL is used with databases. What exactly is a database?

How to Learn SQL: 6 Ideas for Newbies

Learning a new skill can be a daunting task, especially in programming. SQL is not immune to this. Luckily, with the Internet and the explosion of programming-related information out there, there are a lot of options you can use to undergo your SQL training! But we then come to a new roadblock. Where to begin? How will we know which option is best for our budget, skill level, and schedule?

Tag: Get Started With Sql

Top 5 SQL Tutorials for Beginners

Is learning SQL with tutorials a good idea? What tutorials are tailored to your needs? Our top 5 SQL tutorials for beginners will help you find your way! The idea to learn SQL is one of the best you could have. But to succeed, you need a good source of knowledge. In this article, we focus on online tutorials. We will describe different platforms, methods used, key features, prices. After reading this, you’ll be able to choose the best beginner-level SQL tutorial for you.

SQL Indexing 101

Indexes are one of the most misused and misunderstood entities in physical database design. A good understanding of indexes and how they solve database performance problems is necessary for any database novice. In this article, we'll look at basic database indexes and their role in database development. To picture what an index is, consider a textbook. At the end of most textbooks is an index listing all the terms one can find in the text and the pages on which they appear.

Tag: Group By

GROUP BY and Aggregate Functions: A Complete Overview

SQL’s GROUP BY and aggregate functions are essential in data aggregation – and for analyzing data and creating reports. Let’s explore them together!   In SQL, GROUP BY and aggregate functions are one of the language’s most popular features. Data aggregation is critical for data analysis and reporting; to make sense of all the data in a dataset, it often needs to be aggregated. But what is data aggregation? Put simply, it’s when you group data based on common values and perform a calculation for each data group.

SQL HAVING Clause: A Tutorial for Beginners

So, you're new to SQL and have just stumbled upon the HAVING clause. But what does it do? Why is it essential? In this article, we'll delve into the basics of the HAVING clause in SQL. And we’ll walk through practical exercises to enhance your understanding of its functionality. Let's start by defining Structured Query Language (SQL). SQL is a powerful and standardized programming language designed specifically for managing and manipulating relational databases; simply put, it is how we communicate with the databases that hold all of our important data.

SQL Aggregate Functions: A Comprehensive Guide for Beginners

Are you curious about SQL aggregate functions and how they apply to real-world scenarios? In this article, we'll explore SQL aggregate functions, showcase real-world examples, and offer valuable insights on how to master them. Data aggregation is the process of taking several rows of data and condensing them into a single result or summary. When dealing with large datasets, this is invaluable because it allows you to extract relevant insights without having to scrutinize each individual data point.

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.

What Does GROUP BY 1 and GROUP BY 1, 2, 3 Mean in SQL?

Have you ever come across the unfamiliar GROUP BY 1 syntax in SQL queries and wondered what it's all about? Well, you're not alone! In this article, we'll dive into this syntax, explain its purpose, and make it easier to understand. Whether you are a regular SQL user or you’re just beginning to learn this language, you have probably worked with GROUP BY before. The GROUP BY clause in SQL is used to group rows from a table based on one or more columns.

Using GROUP BY and ORDER BY Together: A Guide

Untangling how to use two basic SQL clauses – GROUP BY and ORDER BY – in one query. GROUP BY and ORDER BY are basic SQL clauses. As such, they are taught relatively early in the learning process. And they usually don’t present a big hurdle to beginners. However, using GROUP BY and ORDER BY together can be confusing. By the end of this article, your confusion on this subject will go away.

How to Use COUNT() with GROUP BY: 5 Practical Examples

Using the COUNT() function with GROUP BY is one of the most common SQL constructs in aggregate queries. Read this article to find out how to use COUNT() with GROUP BY correctly using 5 examples. In this article, we will explain the importance of using COUNT with GROUP BY. We’ll talk about why it is essential in SQL and how it enables data analysis and summarization based on specific criteria.

How to Use SUM() with GROUP BY: A Guide with 8 Examples

Explore some real-world examples of using SUM() and GROUP BY in SQL, from the most basic to the most sophisticated. SUM() is a SQL aggregate function that computes the sum of the given values. GROUP BY is a SQL clause that partitions rows into groups and computes a stated aggregate function for each group. Using these two functions together, you can compute total sums for a group of rows. In this article, we’ll see 8 different examples of how you can combine SUM() and GROUP BY to create many different reports.

Free Course of the Month – GROUP BY Extensions in PostgreSQL

Do you work with data? Want to be able to create better and more sophisticated SQL reports? Then check out our interactive GROUP BY Extensions in PostgreSQL course. In May 2023, you can complete this online PostgreSQL course for FREE! How can you get this free SQL course in May 2023? Create a free LearnSQL.com account or log in if you already have one. Start the course.

How to Use CASE WHEN in GROUP BY

Learn how you can combine SQL CASE WHEN and GROUP BY to create custom categories in your SQL queries. Raw data, by its very nature, is not always human readable. Many times, the data you’re querying is in its most unformatted form. Examples of this include codes for different business departments or product SKUs that represent specific products. To the naked eye, these codes mean nothing, so pulling them into a report is not helpful for the person reading them.

How to Group by Multiple Columns in SQL

When analyzing large data sets, you often create groupings and apply aggregate functions to find totals or averages. In these cases, using the GROUP BY clause with multiple columns unfolds its full potential. GROUP BY is a clause of the SELECT command. It allows you to compute various statistics for a group of rows. For example, you can use GROUP BY with an employee table to know how many employees are of each gender.

How to Use WHERE with GROUP BY in SQL

In this article, we’ll discuss how to combine the WHERE and GROUP BY clauses in SQL. If you’re writing SQL on a daily basis, you will quickly realize how often both WHERE and GROUP BY clauses are used. WHERE is an essential part of most queries. It allows you to filter large datasets to only the pieces you are interested in. GROUP BY is one of the most powerful tools an analyst has when aggregating data.

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.

Top 9 SQL GROUP BY Interview Questions

Preparing for an SQL job interview? This guide will walk you through nine basic, intermediate, and advanced GROUP BY questions that you may have to answer. There are common GROUP BY questions that pop up in a lot of SQL job interviews; in this article, we’ll explain how to answer them. If you are a data analyst or another data professional preparing for an interview, this article aims to help you out.

How to Include Zero in a COUNT() Aggregate

Explaining how to include zero (0) counts in your SQL query result. Here’s the problem: you want to count something that doesn’t exist, and you want to show your result as zero. How do you do that in SQL? Using the COUNT() aggregate function is a reasonable first step. It will count all the data it finds and return the number of occurrences. But what if there are no occurrences of certain data?

How to Sort Values in a Specific Order in SQL

Sometimes you will be required to order your data in a particular way, and often the use of typical sort modifiers like ASC and DESC are not enough. This article will show you how to use the CASE statement to order your data exactly how you need it to be. Have you ever needed to order your data in a very specific way? One of the best methods for handling complex sorting is using CASE.

Find Top Salaries by Department with SQL

This article shows how to get the total salary by department for an organization, using the GROUP BY functionality of SQL. We explain the SQL GROUP BY clause in detail along with conditional filtering using a HAVING clause. Understanding the salary outlay for an organization is one of the common starting points for business leaders. It helps them see who in the organization has the highest total salary cost, department-wise.

What Is the SQL GROUPING SETS Clause, and How Do You Use it?

GROUPING SETS are groups, or sets, of columns by which rows can be grouped together. Instead of writing multiple queries and combining the results with a UNION, you can simply use GROUPING SETS. GROUPING SETS in SQL can be considered an extension of the GROUP BY clause. It allows you to define multiple grouping sets in the same query. Let’s look at its syntax and how it can be equivalent to a GROUP BY with multiple UNION ALL clauses.

What Is Advanced SQL?

Are you confused about advanced SQL skills? What are they? This article will explain what advanced SQL can mean, especially as we use it on LearnSQL.com. I’m sure you find the phrases ‘advanced SQL skills’ or ‘advanced SQL topics’ very often. You read one article about advanced SQL and you’re happy with how easy these advanced topics seem to be. Then you talk to someone and you see they consider everything you know as basic SQL knowledge.

New SQL Course: GROUP BY Extensions in PostgreSQL

Do you want to take your knowledge of PostgreSQL to the next level? I have something for you: LearnSQL.com’s new GROUP BY Extensions in PostgreSQL course! It will help you get even more out of your data and create better reports and summaries. Fasten your seat belts and prepare to see what GROUP BY can do when it’s turbocharged. First, I have to confess something. I am not objective – I think PostgreSQL is the best and coolest SQL dialect.

What Is GROUP BY in SQL?

GROUP BY is a great SQL feature that allows you to perform powerful calculations on grouped data. Do you want to learn how to get powerful insights from your data? Would you like to know what GROUP BY does and when you should use it? If your answer is yes, keep reading. In this article, you will learn exactly that. Why You Need GROUP BY In today's digitized world – no matter what business you are in – database tables are usually huge, with millions of records.

Why Aren’t SQL Window Functions Allowed in GROUP BY?

It’s true – the SQL order of operations means window functions aren’t allowed in GROUP BY. But you can use them anyway with this special trick. SQL window functions are one of the language’s most powerful features. However, the syntax of window functions is not easy to master. It has lots of details that can cause beginners to stumble. One of the most common traps is trying to use window functions in GROUP BY.

7 Common GROUP BY Errors

Are you making these errors with GROUP BY in SQL? Find out what they are, how to avoid them, and how to fix them. SQL’s GROUP BY statement can quickly uncover powerful data insights. At first, using GROUP BY can seem easy – e.g. when creating basic SQL reports that you’ll present to business decision-makers. But while learning this powerful feature, you could become trapped in weird errors or get incorrect results caused by improperly written GROUP BY statements.

How to Use CASE WHEN With SUM() in SQL

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. The best way to learn about CASE WHEN and how to use it with SUM() is our hands-on course Creating Basic SQL Reports. It contains over 90 interactive exercises that will teach you different techniques how to create complex reports in SQL.

SQL Course of the Month – GROUP BY Extensions in SQL

Do you want to develop your SQL skills? Do you want to get more out of your data and prepare better reports and summaries? The answer is learning to use SQL’s GROUP BY extensions. But how should you go about this? I asked the same question to Agnieszka Kozubek-Krycuń, Vertabelo’s Chief Content Officer. As she explains, the secret is in this November’s free SQL Course of the Month: GROUP BY Extensions in SQL.

What is the Difference Between COUNT(*), COUNT(1), COUNT(column), and COUNT(DISTINCT)?

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.

How to Fix a 'Not a GROUP BY Expression' Error

Whether you are an experienced SQL user or only a beginner, your SQL queries may return errors. The accompanying messages are supposed to help you fix them; however, sometimes the messages are not very helpful. The Oracle message “Not a GROUP BY expression” is one such example. Let’s review what this is about and how to fix it. We are going to assume some basic understanding of how GROUP BY works.

GROUP BY in SQL Explained

The SQL GROUP BY statement is easy to use, but it can be hard to master. Learn what you can do with GROUP BY, how it works, and how to use it with aggregate functions. GROUP BY is one of the basic SQL tools. However, it might be difficult for beginners to understand how GROUP BY works and how it is used to compute statistics with different aggregate functions. In this article, I’ll use several examples to show exactly how GROUP BY organizes rows and how aggregate functions can be used to calculate statistics on one or more columns.

How to Find Duplicate Values in SQL — The Ultimate Guide

Updated on: November 28th, 2023 Find duplicate values in SQL efficiently and avoid wasting resources. This article demonstrates how to locate and address duplicate records using SQL's GROUP BY and HAVING clauses. Database best practices usually dictate having unique constraints (such as the primary key) on a table to prevent the duplication of rows when data is extracted and consolidated. However, you may find yourself working on a dataset with duplicate rows.

How Does SQL GROUP BY Work?

Grouping results is a powerful SQL feature that allows you to compute key statistics for a group of records. GROUP BY is one of SQL’s most powerful clauses. It allows you to see data in a new way and find key metrics (like the average, maximal, and minimal values in a group of records). Without GROUP BY, all the results we obtain are oriented to records. With GROUP BY, we can create groups of records and calculate metrics on each group.

5 Examples of GROUP BY

When you start learning SQL, you quickly come across the GROUP BY clause. Data grouping—or data aggregation—is an important concept in the world of databases. In this article, we’ll demonstrate how you can use the GROUP BY clause in practice. We’ve gathered five GROUP BY examples, from easier to more complex ones so you can see data grouping in a real-life scenario. As a bonus, you’ll also learn a bit about aggregate functions and the HAVING clause.

The SQL HAVING Clause Explained

What is the SQL HAVING clause? Why do you need it, and where do you use it? We’ll explain HAVING in detail. HAVING is a very common clause in SQL queries. Like WHERE, it helps filter data; however, HAVING works in a different way. If you are familiar with the GROUP BY clause and have only heard about HAVING – or if you’re not familiar with HAVING at all – this article is what you need.

Using GROUP BY in SQL

Now that you know SQL’s core commands, power up your queries with the GROUP BY clause and aggregate functions. GROUP BY is a SQL clause that arranges data into groups based on a common value (or values). It is widely used to obtain summary information for large datasets as well as for computing basic aggregate statistics. Once you have grasped SQL’s basic commands like SELECT, WHERE, and JOIN, mastering the GROUP BY clause can help you implement your SQL knowledge in real-world business intelligence scenarios.

Differences Between GROUP BY and PARTITION BY

Window functions are a great addition to SQL, and they can make your life much easier if you know how to use them properly. Today, we will address the differences between a GROUP BY and a PARTITION BY. We’ll start with the very basics and slowly get you to a point where you can keep researching on your own. PARTITION BY vs. GROUP BY The PARTITION BY and the GROUP BY clauses are used frequently in SQL when you need to create a complex report.

Difference between GROUP BY and ORDER BY in Simple Words

For someone who is learning SQL, one of the most common places to get stuck is when learning the GROUP BY command. GROUP BY and ORDER BY are two important keywords in SQL that we use to organize data. The difference between GROUP BY and ORDER BY is that ORDER BY is more simple than GROUP BY and is usually introduced early in an SQL course. Sometimes, people are quite confused over these two concepts (SQL ORDER BY vs.

SQL Hacks To Control Family Budget On Black Friday Weekend

If you’re in the US, chances are you’ve been eagerly awaiting the approach of Black Friday just as much as Thanksgiving. Though the shopping frenzy takes hold of nearly everyone, some people have to stick to their budgets and shop prudently. In this article, we’ll take a look at how generating an SQL report can help you track how much your family spent shopping on Black Friday. Storing Black Friday Purchases in a Database Before we can create an SQL report, we first need some data we can use.

Tag: Guide

Your Complete Guide to SQL JOINs (with Resources)

This detailed guide covers all important SQL JOIN topics, from basic concepts to advanced techniques. Bookmark this guide for future reference – it’s packed with useful resources and guides to help you work with JOINs effectively. SQL JOINs are essential in SQL and data analysis, as they let you combine data from different tables into a unified view. In this article, I've gathered everything you need to know about SQL JOINs.

The Best YouTube Channels for Learning SQL

Updated on: April 21, 2024 Discovering the best YouTube channel from which to learn SQL is essential for beginners and enthusiasts alike, as SQL learning doesn't have to be challenging. If you're wondering whether watching online videos is the most effective way to master SQL, it's crucial to explore and identify high-quality YouTube channels dedicated to teaching SQL. This approach ensures you gain a comprehensive understanding of SQL through engaging and informative content.

How to Install a MySQL Database on a Windows PC

Do you want to install a MySQL database on your Windows computer? And maybe find out how to start using a MySQL database? In this article, we’ll cover the installation process. MySQL is one of the most popular relational database servers. This is one reason to start using a MySQL database. Among the various editions of MySQL delivered by Oracle, the Community edition is available for free. You can download it from the MySQL website.

2021’s Most Popular Databases

What was the most popular database in 2021? And what do you need to know to use it? If you’re learning SQL, you’re in luck. This year’s most popular database uses SQL. But the list doesn’t end there. Read our article and find out the 5 most popular databases this year. My list was based on the latest research of one of the most important platforms in the IT world: Stack Overflow.

SQL Terms Beginners Should Know - Part 4

Here it is – another batch of must-know SQL terms. In the first two parts, we covered tables, relational databases, queries, aliases, SQL JOINs, primary keys, and subqueries. Last time, we moved to more advanced terms like INSERT INTO, GROUP BY, and HAVING. Are you ready to dive deeper into SQL terminology? This is the fourth installment of our series on basic SQL terms for beginners (and everyone else). Don’t worry if you missed the previous articles; you can find Part 1 (essential SQL terms), Part 2, and Part 3 in our blog.

SQL Terms Beginners Should Know - Part 3

This is the third part of my list of essential SQL terms for beginners. In the first, you learned what tables, relational databases, and queries are. In the second part of the tutorial, I told you about aliases, SQL JOINs, primary keys, and subqueries. Now, it's time for more advanced database terms. But don't be afraid! I won’t crush you with scientific definitions. I will explain everything simply so that you can easily understand.

SQL Terms Beginners Should Know – Part 2

This is the second part of my list of essential SQL terms for beginners. In the first, you learned what a table, relational database, and query are. Now, it's time for more advanced database terms. But don't be afraid! I won’t crush you with scientific definitions. I will explain everything simply so that you can easily understand. If you want to review the basic SQL terms, see my previous article, SQL Terms Beginners Should Know.

SQL Terms Beginners Should Know

Have you started learning SQL? Do you feel a little lost in the maze of new words and ideas? Here’s a list of 10 absolutely essential SQL terms for beginners. When you start learning SQL, there’s a lot to process. And some of it – even basic SQL terms – gets lost in the shuffle. If this sounds like you, bookmark this article; it will be a handy reference.

Five Essential Features of a Good SQL Course

There are many different platforms offering SQL courses. If you’re a beginner, it may be difficult to choose the right one for you. Find out what we think are the essential features of a good SQL course. Remember, if you make a poor choice at the beginning, you may get discouraged or get into bad habits that will impact your work down the line. What Is SQL? SQL, or Structured Query Language, is a programming language you use to talk to databases.

The Most Popular Databases in 2020

Which database solution is currently most popular? Which SQL dialect should you study? In this article, I’ll share the results of my research and my personal experience. Here are the databases that are worth learning SQL to use. First, let's answer some simple questions: Is SQL still useful? Is it worth learning? If you complete an online SQL course, will it make your work easier? The answer is YES! Why?

Top 10 Laptops for Learning SQL in 2020

If you want to learn SQL, you’re going to need a device that’s portable and powerful. I recommend a laptop. Here are the features you’ll need, as well as my picks for laptops to get you learning SQL in 2020! I must admit that browsing Amazon’s computer offers or entering any computer store can give you a headache. So many models, with so many options! They differ in components, workmanship, battery life, and screen size and resolution.

What Is a SQL Dialect, and Which one Should You Learn?

Updated on: September 12, 2023 SQL, standard SQL, SQL Server, MySQL, PostgreSQL, Oracle, … You’d like to learn SQL, but you feel overwhelmed with options and you don’t know where to start. We’ll explain what each of these terms mean and what this has to do with SQL dialects. Diving into the world of SQL dialects can feel like jumping into a deep pool without knowing how to swim. There's a ton of stuff to pick up!

How to Publish a LearnSQL.com Course Certificate on LinkedIn

LinkedIn draws both job seekers and recruiters. Showcasing your knowledge, skills, and experience on this professional networking site can lead to great opportunities. We know this well at LearnSQL.com. Have you finished one of our courses? Great! Tell your future employer about what you have learned. Here's a step-by-step how-to guide for publishing a course certificate on LinkedIn. I will show you how easy it is to publish a LearnSQL.

Last-Minute Preparation Tips for a Database Class Exam

Getting to learn SQL is fun. You don’t really need to spend much time to understand some basic SQL concepts and use them fluently. If you’re a student facing your first database class exam soon, we’ve got you covered. In this article, we explain what you should focus on while learning SQL and studying for an entry-level database exam. Check your knowledge with our 10 sample questions and discover where you can find more SQL practice.

Top 5 Programming Languages to Learn Alongside SQL

If you already know or are about to learn SQL, you’re well on your way to being a sought-after database administrator, database engineer, or just a general database whizz kid! SQL is a modern, widely-used language that finds application in almost every industry. There is no shortage of jobs with SQL. But what if you want to branch out and learn another language to complement your SQL knowledge and skills?

Advanced SQL Courses for Data Analysts – A Complete Review

Even data analysts who already know SQL need to keep their skills sharp. Where can you find the best advanced SQL courses for data analysts? Check out our review of the top online sources! In this article, I present a list of online SQL courses for data analysts. These courses are offered by various platforms. Why wait? Let’s jump right in! 8 Advanced SQL Courses for Data Analysts Let's take a closer look at these courses to decide which platform will be better for you in learning SQL.

How to Practice SQL for a Technical Job Interview

You’ve scored yourself an interview for an SQL-related job. Nice work! But perhaps uncertainty is creeping in as your interview date looms closer. Do you know enough SQL to make the cut? What questions are you likely to be asked? What SQL practice should you be doing before your interview? Almost all SQL job candidates go through exactly the same nerve-wracking process. Here at LearnSQL.com, we have the lowdown on all the SQL practice and preparation you’ll need to ace those interview questions and take your career to the next level.

Is SQL Worth Learning?

We’re in the 21st century. These are the “ultimate data times” in which loads of information on all kinds of things is available. We want to explore this info even more, slice and dice it, understand where it comes from and what triggers it. With such large amounts of data coming in, people have discovered that spreadsheets aren’t enough. There’s a need for a greater solution, something like a spreadsheet on steroids.

Top 3 Platforms to Learn SQL Online: A Complete Comparison

Do you want to learn SQL online? Where do you start? There are many choices on the internet, and it can be hard to decide. But don’t worry—I tested and compared three major platforms to help you find the best place to learn SQL online! E-learning is on the rise. It gives us infinite possibilities of growing our professional careers without leaving our homes. And increasing our competencies is especially important now that the labor market has become dynamic and unstable.

Choose the Best Way to Learn SQL

SQL has become a hot topic in the professional world, and many resources have appeared both online and offline for learning SQL. It’s easy to get lost in the jungle of books, tutorials, and courses. Which resources do you choose? If you want to know how to learn SQL quickly and effectively, take a look at my list. There are many reasons for learning SQL. We asked our users about them and learned that there was no universal motive.

The 50 Best Resources for Learning SQL (Updated for 2024)

Updated on: December 6, 2023 Do you want to know where to learn SQL? We’ve got you covered with the ultimate list of 50 SQL learning resources, including the best SQL courses, tutorials, books, and much, much more! Learning SQL can be hard enough without wading through thousands of websites and articles. So, we thought we’d do you a solid and put the top SQL resources here in this handy slice of the internet.

How to Stay Healthy When Learning SQL

So, maybe you’re learning SQL. Congratulations! Or maybe you already work as a data analyst, DBA, or data scientist. That’s great too! Either way, you are most likely spending hours in front of a computer. I will give you tips on how to avoid bad habits and take care of your health while learning and/or working with SQL. Have you ever wondered how sitting in front of a computer affects your health?

What Programming Language Should You Learn?

If you've ever been wondering which programming language you should learn first, you know that's a tough nut to crack. It’s especially difficult if you are new to IT and programming. In this article, I give suggestions for what to learn first and what perspectives each language can give you in IT. There are hundreds of programming languages, and new ones are showing up all the time. Getting to know all of them is simply impractical and impossible.

How to Study Online: 5 Steps to Effective Learning

If you suffer from procrastination or lack of motivation, you’re not alone. We have some online learning tips to make your learning journey smoother and more enjoyable. One of the best things about being an adult is that we can do what we want: go to sleep late at night, party until morning, eat junk food. Besides all those small pleasures, as adults we are responsible for ourselves, our choices, and our mistakes.

How to Install PostgreSQL on Windows 10 in 5 Minutes

It may look like a complicated task to install PostgreSQL, Oracle, or SQL Server or any other database software, but it really isn’t! These days, most relational database management systems come with installation wizards that make the process much simpler. In this article, we’ll look at how to install PostgreSQL and test that the installation is working. Install PostgreSQL: Steps Involved To install PostgreSQL, we’ll complete the following tasks:

Tag: Having

SQL HAVING Clause: A Tutorial for Beginners

So, you're new to SQL and have just stumbled upon the HAVING clause. But what does it do? Why is it essential? In this article, we'll delve into the basics of the HAVING clause in SQL. And we’ll walk through practical exercises to enhance your understanding of its functionality. Let's start by defining Structured Query Language (SQL). SQL is a powerful and standardized programming language designed specifically for managing and manipulating relational databases; simply put, it is how we communicate with the databases that hold all of our important data.

HAVING vs. WHERE in SQL: What You Should Know

This article is about SQL’s WHERE and HAVING clauses. Both clauses are part of the foundations of the SQL SELECT command. They have similar uses, but there are also important differences that every person who uses SQL should know. Let’s see what’s behind the HAVING vs. WHERE debate. In this article, we’ll suppose we work for a government social agency supporting people or families whose income is below a certain threshold.

Tag: Health

How SQL Helps the Healthcare Sector

Why does the healthcare industry need SQL? Find out how you can use SQL for healthcare in this article. The digital age has ushered in a new era where data is at the heart of every industry. From finance to retail, data drives decision-making and strategy, shaping the way businesses operate and grow. The healthcare sector, with its vast and complex data sets, is no exception to this trend. The rise of digital health records, patient databases, and common integration of hospital inventory management software has underscored the importance of efficient data management in healthcare.

How to Stay Healthy When Learning SQL

So, maybe you’re learning SQL. Congratulations! Or maybe you already work as a data analyst, DBA, or data scientist. That’s great too! Either way, you are most likely spending hours in front of a computer. I will give you tips on how to avoid bad habits and take care of your health while learning and/or working with SQL. Have you ever wondered how sitting in front of a computer affects your health?

Tag: Hierarchical Data

Hierarchical Data and How to Query It in SQL

How do you recognize hierarchical data, and how do you query it? Two common SQL questions are about to be answered. Querying hierarchical data is a rather common situation if you’re working with SQL and relational databases. Not that hierarchical data is something mystical and rare; on the contrary, it’s everywhere. So why is hierarchical data so challenging when it comes to relational databases? Mainly, the difficulties occur in translating hierarchical data to relational database principles.

Tag: History

The History of Slonik, the PostgreSQL Elephant Logo

Logos are powerful. What better way to remind people of a product than an eye-catching, memorable symbol? With that in mind, today we’ll answer the question ‘Why did PostgreSQL choose an elephant for its logo?’ Every product or company has its logo – something that identifies and encapsulates the essence of their brand. In time, it practically becomes the brand: can you imagine McDonald’s without its golden arches? What if the Coca-Cola logo was suddenly done in purple block print?

Tag: How To

Practical Ways to Improve the Performance of SQL Queries

Knowing how to improve SQL query performance is an important skill, especially when working with with large databases. In this article, you'll learn how to write more efficient SQL queries to get results faster. The biggest difference between SQL and other languages is that SQL is a non-procedural language. In a non-procedural language you specify the results that you need but not the methods used to get it. The advantage of a non-procedural language is that it is easier to write programs, therefore it is common for non-programmer business users to generate reports from SQL queries.

SQL Filtering 101

Sometimes, SQL queries return lots of data you don't need. In this article, we'll look at a simple example of filtering SQL queries to reduce the complexity of your data. The key to learning how to filter data in SQL is understanding the very basics of Boolean algebra. That's just a fancy term mathematicians use to describe expressions involving logical values (true/false) and their associated operators (and, or, not, etc.

Improving Query Readability with Common Table Expressions

What is a Common Table Expression, or CTE? Where do you use them, and why? This post answers your questions. Simply put, Common Table Expressions (also known as WITH clauses) are essentially named subqueries. They also provide additional features like recursion. If you're new to subqueries, I recommend you read the SQL Subqueries article before continuing. The main purpose of Common Table Expressions is to improve the design and readability of an SQL statement.

SQL Development? Structured Query Language and Apps

You know about using SQL with databases. How does SQL fit in with app development? Is there anything like SQL development? In this post, we look at the app development process, how it intersects with modeling a database, and what developers can do with SQL outside of their app. Obviously, the beginning of this process is defining your app — what it does, who it is for, how it will function and look, etc.

Performing Calculations on Date- and Time-Related Values

Relational databases support several date and time data types. In this article, we'll look at several arithmetic operations we can do on these types. These operations are logical and understandable, even for the beginning SQL coder. Let's first briefly explain the main data types used for dates and times. Keep in mind that data types may differ by database engine, so check your database documentation for specifics before you start working with them.

Refine Results with SQL Set Operators

Using UNION, UNION ALL, EXCEPT, and INTERSECT to manage SQL query results. The function of SQL set operators is pretty simple; they allow us to combine results from different SQL queries into one result set. The best way to understand how set operators work is to use visual methods like the Venn diagram. For those of you not familiar with Venn diagrams, they are two circles that represent items or collections of items.

6 Common SQL Syntax Mistakes All Learners Make

We all make mistakes when learning a new language – especially at the beginning. New words, complicated grammar... Everyone needs time to master a language. But when we get immediate feedback, we can progress more quickly. The same goes for learning SQL. In this article, we'll look at 6 common SQL syntax mistakes most SQL learners make. Mastering SQL Queries Interactive SQL courses are one way to get immediate feedback on your queries.

8 Tips Absolute Beginners Can Use to Fix SQL Queries

Code errors are common – and frustrating. And when you're just learning SQL, it can be very challenging to find and fix your mistakes. In this post, we'll show you eight ways to solve or eliminate common SQL coding errors. Today, we'll talk about some tips the SQL beginner can use to avoid several common errors. These tips work in any database environment. As we go along, we'll be showing some error messages.

Five Common SQL Syntax Errors

As you learn SQL, watch out for these common coding mistakes You’ve written some SQL code and you’re ready to query your database. You input the code and …. no data is returned. Instead, you get an error message. Don’t despair! Coding mistakes are common in any programming language, and SQL is no exception. In this post, we’ll discuss five common SQL syntax errors people make when writing code.

SQL Errors: Five Common SQL Mistakes

As you learn SQL, watch out for these common coding mistakes You’ve written some SQL code and you’re ready to query your database. You input the code and …. no data is returned. Instead, you get an error message. Don’t despair! Coding errors are common in any programming language, and SQL is no exception. In this article, we’ll discuss five common mistakes people make when writing SQL. The best way to prevent mistakes in SQL is practice.

Tag: How to in Sql

Practical Ways to Improve the Performance of SQL Queries

Knowing how to improve SQL query performance is an important skill, especially when working with with large databases. In this article, you'll learn how to write more efficient SQL queries to get results faster. The biggest difference between SQL and other languages is that SQL is a non-procedural language. In a non-procedural language you specify the results that you need but not the methods used to get it. The advantage of a non-procedural language is that it is easier to write programs, therefore it is common for non-programmer business users to generate reports from SQL queries.

How to Begin Running SQL Queries

In this article, I’ll explain how to run a SQL query to help you execute your first one. Let’s jump right in! Running SQL queries for the first time is not a complex task, but it can seem intimidating at first if you’re a complete beginner. But once you get past that initial roadblock, you’ll be able to focus on learning SQL and writing more interesting queries to meet your business needs.

SQL Indexing 101

Indexes are one of the most misused and misunderstood entities in physical database design. A good understanding of indexes and how they solve database performance problems is necessary for any database novice. In this article, we'll look at basic database indexes and their role in database development. To picture what an index is, consider a textbook. At the end of most textbooks is an index listing all the terms one can find in the text and the pages on which they appear.

How to Use a SQL Wildcard

SQL wildcard allows us to filter data matching certain patterns in SQL. We use SQL wildcards with the LIKE operator in the WHERE clause of a query to filter data. In this beginner’s article, we’ll look at everything you need to know about basic SQL wildcards. If you like playing cards, then you know that wildcards can substitute any other card in your deck. Similarly, SQL wildcards can substitute one or more characters.

SQL Filtering 101

Sometimes, SQL queries return lots of data you don't need. In this article, we'll look at a simple example of filtering SQL queries to reduce the complexity of your data. The key to learning how to filter data in SQL is understanding the very basics of Boolean algebra. That's just a fancy term mathematicians use to describe expressions involving logical values (true/false) and their associated operators (and, or, not, etc.

Why Learn SQL Over the Summer

Think summer is reserved for flying to warm places and hanging out at the beach? Sure! But it's also a great time to learn new skills that you haven't had time for. If you recently graduated from high school and want to get a head start on computer programming for college, learning SQL over the summer is a great opportunity. You have nothing to lose and everything to gain—SQL is actually really easy to learn, especially with so much free time over the summer.

Improving Slow Query Performance: When Runtime Matters

As SQL users, we usually focus on writing queries that return correct results. However, there are more things to consider when you're writing a query; one of them is query performance. In this article, we'll look at some examples where query response time is critical. Scene One: 911 Call Center Let's suppose we're at a 911 call center, when the phone rings. One of the operators answers the call; a witness reports that a man has been shot.

Converting Subqueries to Joins

Not all queries are alike, especially in terms of performance. In this article, we'll look at how you can convert SQL subqueries to joins for improved efficiency. When should I use SQL subqueries? Great question! Unfortunately, there's no concrete answer. SQL beginners tend to overuse subqueries. Typically, once they find that SQL construction works in one situation, they try to apply that same approach to other situations. It's only natural.

Essential SQL Terms to Know for Beginners and Pros

Updated on: April 11, 2024 Working with databases can seem daunting to a non-technical person. Right away, you’re bombarded with new terms that make your head spin. Database, database instance, table, SQL and others are some of the basic terms that you need to understand just to have a normal conversation with your technical colleagues. In this article, we’ll explore some basic SQL database terminology you need to know to succeed.

Learn to Write a SQL Correlated Subquery in 5 Minutes

If you’re familiar with the famous Russian nesting doll, then SQL correlated subqueries should be a peace of cake to understand—subqueries are just queries nested within queries. An SQL subquery is often called an “inner” query; the main query is usually called the “outer” query. This article covers everything you need to know about correlated subqueries. What Exactly is a SQL Correlated Subquery? A correlated SQL subquery is just a subquery that is executed many times—once for each record (row) returned by the outer (main) query.

New LearnSQL.com Online Practice: SQL Practice Set

If you’re looking to retrieve any kind of information from a database, you need to speak its language. But querying databases is an art—and it demands practice. That’s why we created our SQL practice set: a pack of SQL online practice exercises meant to help you master your skills. We spend a lot of time not only developing new courses but also speaking with our users and learning what they expect from SQL online practice exercises.

How to Become a Database Analyst

Curious about becoming a database analyst? Maybe you've taken some database courses at university and they really struck a chord. Or maybe you learned online. Now you're thinking about making a career out of working with databases. Where would you start? What should you expect at each phase of your professional development? In this post, we'll explore the challenging and exciting world of databases analysis. We'll go from the very beginning of a career to the apex of professional success.

Extracting Data From a String: SPLIT_PART in PostgreSQL

Learn how to use split_part in PostgreSQL to extract data from strings. Quite often, we’d like to extract parts of a string when working with text values. A common example is when we have a full name and need to retrieve only the last name. In this article, we’ll examine how to do it using split_part in PostgreSQL, i.e. a string-related function that can be used to extract a substring.

How to Remove Junk Characters in SQL

Unwanted characters in text data can be a bit of a pain, but there’s an easy way to fix them. Scroll down to learn how to remove junk characters in SQL in the easiest way! Sometimes, we’ll find unwanted characters inside our string data because our SQL queries didn’t work as expected. Moreover, these extra characters may sometimes be invisible, which really complicates things. In this article, we’ll examine some string-related SQL functions that can handle unwanted characters—visible or not!

How to Solve Capitalization Data Quality Issues

Misspelled names, typos, and text data quality issues in your database? Power up your queries! Use SQL string functions to address data quality issues related to capitalization. Sometimes, our SQL queries don't work as expected because of data quality issues. In this article, we will examine some string-related SQL functions that can correct data quality issues related to capitalization. We'll be using PostgreSQL in our examples, but similar functions are available in most database engines.

18 Useful Important SQL Functions to Learn ASAP

Updated on: October 30th, 2023 Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike.

Simplify SQL Code: Recursive Queries in DBMS

Hey SQL users! Are you repeating the same query in every report? Are your queries getting too complicated? Use recursive queries to simplify SQL code! Too many SQL reports can lead to clutter on your desktop and in your head. And is it really necessary to code each of them separately? Ad-hoc queries can share much of the same SQL code with managerial reports and even regulatory reports. Suppose you’ve been writing basic SQL code for a while.

Analyzing Survey Data: Explore Results Using SQL

Excel is a powerful beast that lets you analyze complex data. Yet, operating on big chunks of data can sometimes be a daunting task. Let's take a look at how SQL can help. Today, we'll tackle a common problem with importing data to an SQL database, using a real-life example. Suppose your company conducted a survey on the most popular programming trends and preferences, striving to meet the expectations of its users.

SQL Hacks To Control Family Budget On Black Friday Weekend

If you’re in the US, chances are you’ve been eagerly awaiting the approach of Black Friday just as much as Thanksgiving. Though the shopping frenzy takes hold of nearly everyone, some people have to stick to their budgets and shop prudently. In this article, we’ll take a look at how generating an SQL report can help you track how much your family spent shopping on Black Friday. Storing Black Friday Purchases in a Database Before we can create an SQL report, we first need some data we can use.

SQL Window Functions By Explanation

In our previous post, we explained how SQL window functions work by example. We started with some very simple, basic functions. Let's extend it by explaining subclauses in window functions. SQL window functions are a great way to compute results from a set of rows rather than a single row. As you know from our first article, the "window" in window function refers to the set of rows. We showed you some examples of simple window functions like RANK and LEAD.

The 5 Highest Paying Jobs That Use SQL

IT provides a wide and growing job market, offering many excellent opportunities in both career development and earning potential. Today we’ll take a look at several very interesting types of database jobs that use SQL. Every year, many in the work force set their sights and aim for new and better jobs. When it comes to jobs, “better” means different things to different people, but earning potential is almost always a top priority.

Four Reasons You Must Learn SQL in Data Science

Is SQL important for data science? It certainly is! This language can help you build a foundation for your analytical career. Let’s see how you use SQL in data science. Data science is hot right now. What if you could predict the next market crash? Or contain the spread of Ebola? Or accurately predict a health crisis months or even years before it happens? Data scientists are working hard on these kinds of projects, and they are earning healthy salaries in the process.

5 Reasons Why No One Should Be Afraid to Learn SQL

Updated on: September 17, 2023 Think SQL is just for tech experts? Think again. In this article, we'll bust some common myths and show you that anyone can learn SQL. Let's dive in and make SQL simple. In today’s world, even those in non-technical jobs need some technical skills. And you don’t have to be a hard-core nerd to get these skills. Everywhere you look, from marketing to management, a touch of tech knowledge can set you apart.

SQL Set Operators: Union, Union All, Minus, Intersect

Ever heard terms such as union and intersection in SQL? They're examples of set operators, and they come in handy when you need to combine information from multiple tables or queries. In this article, we'll take a closer look at them. SQL queries let us choose the most important bits from large amounts of information. Of course, we can't expect that all necessary data will be stored in one table.

Improving Query Readability with Common Table Expressions

What is a Common Table Expression, or CTE? Where do you use them, and why? This post answers your questions. Simply put, Common Table Expressions (also known as WITH clauses) are essentially named subqueries. They also provide additional features like recursion. If you're new to subqueries, I recommend you read the SQL Subqueries article before continuing. The main purpose of Common Table Expressions is to improve the design and readability of an SQL statement.

Complete SQL Practice for Interviews

Congratulations! Your SQL skills were strong enough to get you that job interview! Now, if you only knew what SQL questions and practical exercises a recruiter might ask you to do… This article is meant as a SQL practice for interviews. I’ll help you prepare for the SQL and database aspects of your job interview. In a previous article, I explained how can you boost your career by learning SQL.

SQL Development? Structured Query Language and Apps

You know about using SQL with databases. How does SQL fit in with app development? Is there anything like SQL development? In this post, we look at the app development process, how it intersects with modeling a database, and what developers can do with SQL outside of their app. Obviously, the beginning of this process is defining your app — what it does, who it is for, how it will function and look, etc.

The Complete Beginner’s Guide to SQL Fundamentals

LearnSQL.com is a great place to learn SQL. If you’re a complete beginner, it’s best to have an overview of what SQL is, what a database is, and how they work together. In this article, you’ll find a complete guide to SQL fundamentals. SQL Fundamentals: Database Let’s begin our guide to SQL with basic definitions. You might have already heard that SQL is used with databases. What exactly is a database?

Performing Calculations on Date- and Time-Related Values

Relational databases support several date and time data types. In this article, we'll look at several arithmetic operations we can do on these types. These operations are logical and understandable, even for the beginning SQL coder. Let's first briefly explain the main data types used for dates and times. Keep in mind that data types may differ by database engine, so check your database documentation for specifics before you start working with them.

Refine Results with SQL Set Operators

Using UNION, UNION ALL, EXCEPT, and INTERSECT to manage SQL query results. The function of SQL set operators is pretty simple; they allow us to combine results from different SQL queries into one result set. The best way to understand how set operators work is to use visual methods like the Venn diagram. For those of you not familiar with Venn diagrams, they are two circles that represent items or collections of items.

6 Common SQL Syntax Mistakes All Learners Make

We all make mistakes when learning a new language – especially at the beginning. New words, complicated grammar... Everyone needs time to master a language. But when we get immediate feedback, we can progress more quickly. The same goes for learning SQL. In this article, we'll look at 6 common SQL syntax mistakes most SQL learners make. Mastering SQL Queries Interactive SQL courses are one way to get immediate feedback on your queries.

8 Tips Absolute Beginners Can Use to Fix SQL Queries

Code errors are common – and frustrating. And when you're just learning SQL, it can be very challenging to find and fix your mistakes. In this post, we'll show you eight ways to solve or eliminate common SQL coding errors. Today, we'll talk about some tips the SQL beginner can use to avoid several common errors. These tips work in any database environment. As we go along, we'll be showing some error messages.

How to Learn SQL: 6 Ideas for Newbies

Learning a new skill can be a daunting task, especially in programming. SQL is not immune to this. Luckily, with the Internet and the explosion of programming-related information out there, there are a lot of options you can use to undergo your SQL training! But we then come to a new roadblock. Where to begin? How will we know which option is best for our budget, skill level, and schedule?

Five Common SQL Syntax Errors

As you learn SQL, watch out for these common coding mistakes You’ve written some SQL code and you’re ready to query your database. You input the code and …. no data is returned. Instead, you get an error message. Don’t despair! Coding mistakes are common in any programming language, and SQL is no exception. In this post, we’ll discuss five common SQL syntax errors people make when writing code.

SQL Errors: Five Common SQL Mistakes

As you learn SQL, watch out for these common coding mistakes You’ve written some SQL code and you’re ready to query your database. You input the code and …. no data is returned. Instead, you get an error message. Don’t despair! Coding errors are common in any programming language, and SQL is no exception. In this article, we’ll discuss five common mistakes people make when writing SQL. The best way to prevent mistakes in SQL is practice.

Tag: Ide

Best SQL IDEs for You

Maybe you just started learning SQL. Maybe you already have some experience. Whatever your situation is, choosing the right IDE for you is another step in your development. Why IDE? IDE stands for integrated development environment. It is a software application that enables us to combine various aspects of writing a computer program. An IDE usually contains a source code editor, build automation tools, and a debugger. You might ask why you need an IDE when you have the command line available on your computer.

Tag: Insert

What Is the INSERT Statement in SQL?

The INSERT statement in SQL is used to add new data to your database. This article will explain how to use it and show you practical examples along the way. When you learn SQL, you focus on getting data out of a database, working mostly with SELECT. In SQL, there are also statements that let you modify data in a database. The first one is the INSERT statement: it adds data to a table.

Learn SQL Views in 30 Minutes

Views aren't complicated – if you've got half an hour, we'll get you started writing SQL queries using views! Let's start by answering the question "What is a view in SQL?'. A view is a database object (as is a table, an index, or a stored procedure). Like a table, you can query a view and extract the information in it. It can be used in the FROM clause of a SELECT, and you can reference view columns in clauses like SELECT, WHERE and GROUP BY among other clauses as well.

Using CASE with Data Modifying Statements

What happens when you combine CASE with SQL's data modifying statements? Find out in this article. The CASE expression is a very useful part of SQL and one that you'll employ frequently. We've already covered what the CASE expression does, how to format it, and how to use it in a SELECT statement in "Using CASE to Add Logic to a SELECT". Another article, "How to Sort Records with the ORDER BY Clause"

Tag: Installation Guide

How to Install MySQL on Ubuntu

Looking to install MySQL on Ubuntu? Delve into the world of efficient data management with this comprehensive guide. From updating your package list to securing your installation and ensuring smooth configurations, these step-by-step instructions will help you seamlessly set up MySQL on your Ubuntu system. If you’re reading this article, you’re seriously interested in working with data. What you need is a suitable tool to make it happen. If you’re considering installing MySQL on an Ubuntu Linux system, you may wonder if this combination is a good choice.

How to Install MS SQL Server 2019 on Windows

Do you want to install SQL Server 2019 on your Windows PC? How about the latest version of SQL Server Management Studio? I’ll walk you through the process. Soon you’ll be writing T-SQL queries and operating on SQL Server databases! As I write this article, Microsoft SQL Server 2019 is the latest version of SQL Server. It’s the 15th version of one of the most popular database servers in the world.

Microsoft SQL Server 2017 Installation Step by Step

Microsoft SQL Server is one of the most popular professional database servers on the market. In this guide, I’ll show you all SQL Server 2017 installation steps to help you install it on the Windows operating system together with SQL Management Studio. If you want to learn T-SQL, the dialect of SQL used in SQL Server, check out our SQL from A to Z in MS SQL Server track.

How to Begin Running SQL Queries

In this article, I’ll explain how to run a SQL query to help you execute your first one. Let’s jump right in! Running SQL queries for the first time is not a complex task, but it can seem intimidating at first if you’re a complete beginner. But once you get past that initial roadblock, you’ll be able to focus on learning SQL and writing more interesting queries to meet your business needs.

Tag: Intersect

What Do the SQL INTERSECT and MINUS Clauses Do?

Do you know the difference between SQL’s INTERSECT and MINUS clauses and how to use them? You will find examples and explanations in this article. SQL INTERSECT and MINUS are useful clauses for quickly finding the difference between two tables and finding the rows they share. INTERSECT compares the data between tables and returns only the rows of data that exist in both tables. MINUS compares the data between tables and returns the rows of data that exist only in the first table you specify.

Tag: Interview

MySQL Crash Course - An Interview With Rick Silva

If you've read my articles before, you probably already know that I love reading. What's more, I also collect SQL books. It may sound weird, but I enjoy comparing different approaches and ways of writing about databases. The best ones end up in our recommended books lists, like The Best SQL Books. One of those books, MySQL Crash Course, has just been released. I was able to talk to its author, Rick Silva, and this is what he told me.

Tag: Jobs and Career

SQL Interview Questions for Data Analysts

You have an upcoming interview for a data analyst position and SQL is one of the skills that will be tested. Well, these SQL questions for data analysts are specifically tailored for you! SQL is a must-have skill in every data analyst's toolkit. It simplifies data extraction and manipulation, allowing analysts to convert raw data into actionable insights. It enables analysts to perform ad hoc analyses, accelerating organizational decision-making processes.

Is the Data Analyst Still in Demand in 2024?

In 2024, the demand for data analysts will rise as businesses increasingly rely on data to make strategic decisions. In this article, we explore the importance of data analysts in shaping the future of data analysis. With the rise of AI, many wonder if the demand for data analysts will remain strong. After all, the data analytics industry has witnessed a remarkable transformation. It’s evolved into a pivotal force driving decision-making processes across various sectors.

Building a Data Analyst Portfolio: All You Need to Know

In a competitive job market, it is not enough to simply have the necessary skills; you must also demonstrate them. This is where a well-crafted data analyst portfolio comes into play. In data analytics, a portfolio is more than just a collection of projects; it serves as proof of an analyst's abilities and is critical to standing out. It demonstrates concrete capabilities in data cleaning, analysis, and visualization as well as the ability to effectively communicate insights.

This Advanced SQL Course Will Boost Your Career!

Can you already create pretty good SQL reports? Do you want to take it a step further? In this article, I'll explain how an advanced SQL course can propel you (and your career) to the next level. Since you are looking for information about SQL, you probably already know how important data is nowadays. Very few companies can stay on the market without using the power of data or basing their strategic decisions on it.

Business Analyst v. Data Analyst: Roles & Career Paths

Are you interested in working as a data analyst or business analyst? What’s the difference between these two roles? We explain the data analyst vs. business analyst debate in this article – and give you a pathway for success in either job. The demand for individuals skilled in decoding complex data has reached new heights in the ever-changing business landscape. Among the many roles available, business analysts and data analysts each have their own responsibilities, skill sets, and career paths.

Why Every Database Administrator Needs SQL

What is a database administrator? What do they do? Why do they need to know SQL, and what do they use it for? In this article, I'll answer these questions. As technology advances, more and more data is available to help organizations make informed decisions. You can't stay competitive – or provide good service to your customers – without the right information. Database administrators are responsible for making sure the right data is stored safely, that it's easily accessible to those who need it, and that it’s protected from malicious attacks.

This Is the Best SQL Assessment to Boost Your Career

What’s an SQL assessment and why would you need one? Where can you find a free and reliable gauge of your SQL skills? Find out in this article. In today's data-driven world, proficiency in SQL is more than just a skill—it's necessary. Whether you're looking to explore and analyze data to derive actionable insights or to store, manage, and optimize data in a relational database, having a solid foundation in SQL can significantly boost your resume.

SQL for Project Managers: Enhancing Decision-Making

Did you know that SQL is a vital component in the project manager’s toolkit? In this article, we'll delve into how SQL for project managers enhances their workflow, promotes informed decision-making, and boosts operational efficiency. Data has become the foundation of decision-making across industries. In today's data-driven world, it's critical to arm yourself with the correct tools for dealing with the influx of data. One such tool that has stood the test of time is Structured Query Language, better known as SQL.

How to Prepare for an Advanced SQL Interview

Tips and tricks to help you ace even the most advanced SQL interview questions. SQL has become the lingua franca of data – the standard method for interacting with databases, extracting insights, and conducting analytical tasks. As a data analyst, the ability to understand and manipulate SQL code is not just a 'nice to have'; it's an absolute necessity. For many data analyst roles, a basic understanding of SQL isn't enough.

Data-Driven Career Choices: Database Student

Choosing a career is one of the most important decisions you'll ever make. A data-driven career is one of the best ways to secure your future; today's trend is to store and make use of more and more data in every field. In this article, I'll look at some of the choices available. We're living in an era where the quality and quantity of data is expanding exponentially. In almost any career you choose, you'll need to leverage data to make effective decisions.

How SQL Skills Can Boost Your Resume

You may wonder: does having SQL skills matter? In what areas could I use my SQL skills? In this article, I will explain how having SQL skills can boost your resume and add momentum to your professional career. We are living in the Big Data era. Every time we go online, we provide the websites we visit with a lot of information. If we voluntarily give our data by creating an account, filling out a form, or making a purchase, we give them even more information.

Who Is a Data Manager?

Who are data managers? What are their responsibilities, and how do I become one? We’ll answer these questions and get you on your way to becoming a data manager! Simply put, data managers oversee the management of information or data within an organization. They manage data organization, storage, security, and accessibility, and they collaborate with other team members to guarantee data accuracy and usefulness in supporting decision-making. To ensure that data is effectively managed and used appropriately, they may also develop and implement policies and procedures pertaining to data management.

How I Used SQL to Advance in My Career

Updated on: April 18, 2024 SQL has become increasingly valuable in today’s job market.  In this article, I will share my personal experience with SQL. I hope it will inspire you to grow in your career and achieve your own goals! A few years ago, I felt stuck in a job that I didn’t fully enjoy. Sure, there were aspects of my job that I appreciated, like building budgets, analyzing the performance of promotional programs, and watching my team grow professionally.

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.

SQL for the Business Analyst

How can SQL benefit business analysts? In this article, we’ll discuss why SQL is a fundamental skill in this role. You’ll also learn what a business analyst does and what they need to advance their career. According to BrainStation, the already high demand for business analysts is set to grow even more. One of the driving forces behind the rising demand is the digital revolution, which has been accelerated by the recent pandemic.

Database Jobs to Choose in 2023

In this article, we will explore some of the top database jobs to choose from in 2023. So you want to land yourself a database job in 2023. It’s a great choice, and there are lots of options. Let’s talk about the most popular data-related jobs and what you need to do to get one. SQL Is Essential for a Database Job It’s important to mention that most of the popular databases nowadays are relational – i.

Want to Get a Data Engineering Job? Learn SQL!

So, you want to be a data engineer, but you don't know how to get there. In this article, we’ll help you understand the skills you'll need for different types of data engineering jobs. You’ll also find some data confirming that data engineer jobs are a good career choice. Data engineering and various types of data engineer jobs have become very popular in recent years. And for good reason: Next to data science, data engineering is one of the fastest-growing branches of IT.

Why You Need Analytical Skills to Get Promoted at Work

Do you wonder if analytical skills might benefit you in your job? Are ‘analytical skills’ the same as data analytics? Is SQL a useful analytical skill? Read the article to answer these questions. Analytical skills allow you to better understand problems in your work; good analytical skills bring many benefits to your career. The term ‘analytical’ refers to a wide range of traits and capabilities, making it sometimes ironically vague and general.

SQL Courses for Software Testers

In this article, you will learn why software testers need SQL and which courses are ideal for them to learn it. Do software testers need SQL? Oh yes, they do! They don’t necessarily use it all the time or take advantage of all its possible features. But a tool for accessing data in a database is essential for a software tester. And SQL is exactly that: a programming language designed specifically for handling data in relational databases.

How Much Do Business Analysts Earn?

What does a business analyst do, and why are they essential to their companies’ success? What skills do you need to become a business analyst? How much can you expect to earn? We’ll answer all those questions in this article. With our dependence on digital systems increasing by the day, IT and IT related jobs like business analysts are seeing a continuous boom in opportunities. Did you know that IDC estimates around 60% of the global GDP will be mostly impacted by the introduction of digital tools by the end 2022?

Top 10 MySQL Interview Questions And Answers

You learned SQL and now you want to use this valuable skill to get a better job. Now it’s time to prepare for the job interview. We’ve got ten MySQL interview questions and answers to help you with that. In today's hyperconnected world, knowing how to deal with it has become a necessary skill. That’s why you probably learned (or want to learn) SQL: either your job requires it or you realized that you need SQL to get a better job.

Prepare for a SQL Interview with LearnSQL.com

You've been working hard to get a SQL interview at your dream company. Now they’ve called – and you need to prepare if you’re going to ace it. In this article, I’ll show you the most efficient way to prepare for a job interview using the interactive SQL courses at LearnSQL.com. SQL is an essential skill for anyone working with data. Wanna be a data analyst, data scientist, software engineer, or tester?

5 Tips for You From a Senior SQL Data Analyst

Are you looking for tips for becoming a better data analyst? Do you want to know about the mistakes and issues you may face? I have collected five tips for your everyday work based on my experience as a data analyst. You may have already read about what data analysts do, how much they earn, and how to become one. However, there is more to it than just becoming a data analyst.

Top 9 SQL GROUP BY Interview Questions

Preparing for an SQL job interview? This guide will walk you through nine basic, intermediate, and advanced GROUP BY questions that you may have to answer. There are common GROUP BY questions that pop up in a lot of SQL job interviews; in this article, we’ll explain how to answer them. If you are a data analyst or another data professional preparing for an interview, this article aims to help you out.

PostgreSQL Interview Questions and Answers

Job interviews are always stressful. Interviewing and getting asked technical questions about PostgreSQL is even more of a challenge! In this article, we’ll cover some of the PostgreSQL interview questions you can expect when applying for a new job. By the end of the article, you should be able to handle most of the questions you are likely to face. We’ve previously covered common questions you can expect at a SQL job interview, but this article will be focused on Postgres specifically.

Top 5 SQL CTE Interview Questions

Here are five questions (and solutions!) on CTEs you’ll (probably) be asked at an interview. I’m not saying you will get these SQL CTE interview questions at every job interview. But when you do, they are probably along the lines of the five I’m about to show here. Other than theoretical questions about CTEs, there are not that many variations in the CTE scenarios evaluated by interviewers. Go through these five examples, and you get a good foundation for acing your interview!

SQL for Startups – Do You Need It?

If you’ve been wondering whether to use SQL in your startup, it’s probably high time to do so. SQL can be an amazing tool for small, fast-growing businesses. But don’t worry if you’re unfamiliar with SQL for startups. Maybe you are not sure what SQL is all about. Don’t worry; you don’t have to make any decisions this second! First, answer these questions: Can you think of any data related to your business – prices, clients, details about clients, production details, budget, costs, strategy, or anything else?

How SQL Helps Everyone in Your Office

I don't know about you, but I really like to make my life easier. If something can be done faster and more efficiently, especially if it's everyday, routine tasks, I’m all for it! This is where SQL works brilliantly. It's not just about complicated data analysis. Everyone in the office works with different types of data, and SQL can help anyone. How? Anything is possible once you learn SQL!

How to Show Your Sql Experience

Do you want to work in the IT industry? This is now one of the best ideas for a good career. What should convince you to do so? Demand for specialists, high earnings, and the fact that it is a future-proof profession. Interestingly, it's not gonna be that hard – especially for you, smartie! You just need some skills and good preparation for an interview to be successful. I'll tell you how to land a great job!

How Much Do Data Analysts Earn in 2021?

How Much Do Data Analysts Earn in 2021? How much does a data analyst earn? We did some data analysis ourselves. Nothing fancy, but it will give you some extra motivation for learning SQL for your data analyst gig. Data, data everywhere! We live in the world of (big) data. Having data is just the first step. Knowing what to do with it, how to interpret it, and what insights it holds, is true greatness.

How to Improve New Employee Onboarding with SQL Courses

Are you looking for something to improve the onboarding process of new employees at your company? If they will be working with databases and SQL, and if you need resources for them to learn quickly, choose interactive SQL online courses. You’ve just hired some new employees. Great! After a long recruitment process, you have finally managed to find people who can do the job and meet your expectations. You may have even used our advice on why it makes sense to Practice SQL Before Interviewing a Potential Employee.

Top 10 SQL Window Functions Interview Questions

Many interesting job positions require SQL skills – and that includes window functions, which are not commonly taught in online courses. In this article, I will cover the top window function questions for every experience level. If you’re going for a job interview for an advanced SQL position or for intermediate to advanced data analyst positions, you’ll probably be asked about your knowledge of SQL window functions. Don’t panic! Although these functions aren’t commonly covered in online courses, we’ve got the answers right here.

Best SQL Certifications for Leveling up Your Career

If you want to build and strengthen your position in the IT industry, you should look into these SQL certifications. We always encourage you to learn, to gather new skills and experience. Training is really important; without it, you will not make much progress if you want to advance in IT or specifically in the SQL industry. That said, you also need something that can validate your competencies, like SQL certifications.

Top 15 SQL Interview Questions in 2021

If you are on the lookout for a job in the field of data, you’re almost guaranteed to face SQL interview questions. You might even be asked to complete some kind of SQL coding test. According to KDnuggets, irrespective of the specific role in data – data analyst, data engineer, data scientist, or business intelligence analyst – SQL lands in the top three skills found in postings across Indeed, SimplyHired, and Monster.

Skills Every Data Analyst Should Have

If you’re a student looking for career advice or a specialist seeking new job opportunities, find out if a data analyst job is something worth considering. In today's article, I explain the essential skills required for data analysts and benefits that come from performing such a job. What Is a Data Analyst? Let’s start by defining exactly what a data analyst is. A data analyst is someone who uses their skills to collect, analyze, and report insights from company data.

Where Can I Find a Data Analyst Internship?

Are you wondering how to land a data analyst job without any professional experience? This article is the answer! Finding an SQL-related internship – an important part of eventually landing a data analyst job. Internships enrich your CV and, more importantly, help you learn SQL from the practical side. I will tell you where to find data analyst internships and what you should know about them. That's right! To gain experience, you need experience – especially when you’re entering the labor market or embarking on a new career.

Want to Work With Data? Learn SQL!

Are you looking for a database job? How are things working out? If you don't know what to do, I suggest you start by learning SQL. Here’s why. In this article, I’ll explain how you can succeed at finding a database job. If you are tired of your current job and fed up with your boss (who hasn't given you a raise in years), read on. Stay with me too if one more stupid Zoom call will make you scream.

Practicing SQL for Your First Day of Work

Your new SQL job is likely to surprise you in many ways. To minimize the risk of getting lost in the jungle of data, I recommend you get some additional SQL practice before your first day. There are special SQL practice sets and projects on the internet to help you prepare. You’ll also get help from your colleagues, as programmers are usually open and supportive. If you’re reading this, you’ve probably heard about the opportunities SQL and data science offer.

The Top 10 SQL JOIN Interview Questions with Answers

Have you ever wondered what SQL JOIN questions you might be asked in an interview? Do you feel prepared to answer them? This article covers the most common SQL JOIN interview questions and how to answer them. If you are applying for a job as a data analyst or software developer, you will likely be asked about your SQL JOIN knowledge. SQL JOIN clauses are a great topic for interviewers to quiz you on.

Practice SQL Before Interviewing a Potential Employee

Has your company grown to the point that you need to hire an SQL expert? Have you found a candidate for the job? How do you prepare for the interview, especially if you don’t know SQL? Don't worry! Follow our suggestions on how to practice SQL. We have tips and tricks to help you feel confident and find the perfect employee. Who You Want To Hire First of all, you need to know the requirements for the new employee.

How to Boost Your Company With SQL Courses

SQL has the power to supercharge the capabilities and performance of your entire company. But if you don’t dip your toes in the water and give some SQL courses a go, you’ll never realize the vast potential of the language. SQL, or Structured Query Language, is your ticket to expanding the scope and the results of your business or organization, no matter what sector you operate in. Whether you’re the owner or manager of your company or simply an employee interested in improving operations, learning SQL is undoubtedly, unquestionably, for you.

How Will Learning SQL Make You a Better Boss?

Updated on: April 6, 2024 Looking to enhance the performance of your team, elevate your own productivity, or boost the efficiency of your entire department or company? Consider learning SQL! Why? Because its benefits are substantial and the return on investment is significant. What does learning SQL and being a better boss have to do with each other? Being a better manager can make your employees happier while growing your business.

How Much Do Data Engineers Earn in 2020?

Data engineering is a hot job right now. What does a data engineer do? And just how much do they earn? We’ve done the research for you. If you are reading this, you’re either starting to learn SQL or you already know some and feel it’s time to look around for a SQL job. Maybe you’re in the midst of tackling our Creating Database Structure track. And, let’s be honest, maybe you need some extra motivation to keep on you track.

Why and How to Find Freelance SQL Jobs

If Covid-19 has you all “I-want-to-stop-working-for-the-man-and-enjoy-a-more-fulfilling-life-as-the-master-of-my-own-destiny”, then I’ve got news for you. Not only is it possible to be an SQL freelancer, it’s also a potentially lucrative and liberating career move. It will allow you to work for a diverse range of clients and march to the beat of your own drum. Of course, SQL freelancing isn’t for everyone. You will need a strong sense of self-motivation, some serious hustling skills, and the ability to sell yourself and your services as THE ABSOLUTE BEST all the time, every time - day in, day out.

How to Convince Your Boss You Need SQL Training

Learning SQL is a great goal. Now, if you could only convince your boss that it’s good for the company as well as for you ... You’re aware of the benefits of adding SQL to your skill set. You believe that the rewards gained from you learning SQL will also benefit your employer – it’s not just another way for you to develop your professional profile. But how do you articulate this to your boss?

Major Companies Using PostgreSQL: Purposes & Examples

Which companies use the open-source relational database management system PostgreSQL? Find out … and learn why you should be a PostgreSQL user too. You know the blue elephant logo. You have heard that PostgreSQL is a very good solution. But which companies use it? Here is a list of the largest IT and business companies that use PostgreSQL (or Postgres, for short). Multinationals worth billions of dollars can't be wrong, right?

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.

How to Practice SQL for a Technical Job Interview

You’ve scored yourself an interview for an SQL-related job. Nice work! But perhaps uncertainty is creeping in as your interview date looms closer. Do you know enough SQL to make the cut? What questions are you likely to be asked? What SQL practice should you be doing before your interview? Almost all SQL job candidates go through exactly the same nerve-wracking process. Here at LearnSQL.com, we have the lowdown on all the SQL practice and preparation you’ll need to ace those interview questions and take your career to the next level.

Are There Any Good SQL Courses for Marketers?

Looking for places to learn SQL online and level up your marketing efforts? Check out these SQL courses. Introduction With the help of IT experts, meticulous marketers analyze information to create advertising strategies. This commonplace state of affairs forces the marketer to rely on data experts and sometimes wait for their availability. But what if marketers could pull the data themselves? They can – by turning into a technical marketer.

Types of Database Jobs

Updated on: April 11, 2024 Do you dream of high earnings and interesting work? Are you fed up with your boss and his or her annoying vacation stories in exotic countries? Is it time to change your job? Why not learn SQL? Here are some examples of the types of database jobs that may lead you to a better life. What types of database jobs use SQL? Here are some examples, but first, a small caveat.

How Will Learning SQL Improve My Daily Work?

Whether you want to boost your professional development, learn in-demand skills, or start something new and interesting, learning SQL will make your life easier in many ways. Are you thinking of learning SQL but aren’t sure if it's a good idea? At first glance, learning SQL may seem completely useless, especially if the industry you are in is not related to IT. But that's not true. Although your position in the company may not imply that you code every day, you can still gain a lot from SQL.

Should I Learn SQL as a Data Analyst?

So, you are a data analyst—someone who relies on data. You like to gather, clean, and transform data and come to conclusions based on data. You are a data detective. Which tool do you choose to do your job in an elegant, reproducible, and simple way? Excel? R? Python? Or should you learn SQL? Stay tuned! In this article, I will explain why SQL is a must-have skill for data analysts.

Top 10 Websites That Will Help You Find the Perfect SQL Job

Updated on: March 6, 2024 People learn SQL for many reasons. In my case, I wanted to find a better job that would allow me to earn more and have more free time. But where do you find such a job? Here is my list of the 10 best websites with database jobs. Although SQL is over 40 years old, it is appearing in more and more job advertisements. Data has become an essential tool for businesses, and they are looking for people to squeeze every bit of information from their databases.

Common Entry Level SQL Developer Interview Questions

Have you ever been interviewed for an entry-level SQL position? Are you planning to apply for such a job? This article will help you to know what to expect and prepare for common SQL developer interview questions. After gaining some basic knowledge of SQL and programming, you're probably wondering what to do next. Or maybe you're not wondering! You know that what you've learned will soon disappear if you don't use it regularly.

How to Become an SQL Developer

There is no simple answer to the question “How do you become an SQL developer?” However, if the answer were too complex, there would be no point in writing this article, and yet I’m doing it. So, somewhere along the way, we’ll find the answer. As said in the intro, there is no magic wand that will turn you into an SQL developer. But reading this article will save you some time and help you focus on what is important to achieve your goal.

Why Use SQL Over Excel

SQL is replacing Excel in many fields, and data analysis is certainly one of them. If you are still using Excel as a data analyst, you are missing something very valuable. SQL can make your life easier, as it's more efficient and faster than Excel. So, how and from where can you learn SQL? How Can SQL Help Data Analyst? You can use SQL to help you with the following work:

Career Change: From Accountant to Database Designer

How do career changes and life choices impact our future? Can we change the path that's been set for us? And if so, where do we begin? I wouldn't blame you if you thought this article is about change. In a sense, it is—it's in the title, after all. But for me, this article is more about what remains constant. If somebody were to ask me what hasn't changed for me since my childhood, I would know the answer immediately: curiosity.

Complete SQL Practice for Interviews

Congratulations! Your SQL skills were strong enough to get you that job interview! Now, if you only knew what SQL questions and practical exercises a recruiter might ask you to do… This article is meant as a SQL practice for interviews. I’ll help you prepare for the SQL and database aspects of your job interview. In a previous article, I explained how can you boost your career by learning SQL.

Finding the Perfect SQL Job

So you have some SQL skills and you're looking for a job that will use them. What are your options? SQL is everywhere, and there's a huge demand for people with database management skills. This is especially the case when companies start implementing Big Data solutions and strategies. There's no arguing that SQL is a must-have skill. If you're already proficient, how can you put your expertise to practical use in the job market?

A Day in the Life of a SQL Developer

What is a SQL developer? And what does a SQL developer do? Describing a “typical” day for a SQL developer is not easy. When your daily work is using various technologies to create interesting database-oriented products, very few days are alike! Each day brings a new and intriguing challenge. Nevertheless, I’ll have a go at explaining what everyday things a SQL developer might do. Morning: Arrive at Work What does a SQL developer do after arriving at the office?

Tag: Join

What Is CROSS JOIN in SQL?

What is a CROSS JOIN in SQL, and when should you use it? We answer those questions – and give you some examples of CROSS JOIN you can practice for yourself – in this article. Imagine you're looking through your wardrobe for outfit ideas, wondering which top to wear with which bottom. When you think of the perfect outfit, you envision all of the tops and bottoms in your closet combined.

RIGHT JOIN in SQL: A Beginner's Tutorial

Learn RIGHT JOIN, a crucial command for any SQL specialist. Our article breaks down this essential technique, helping beginners effortlessly navigate and apply RIGHT JOIN in their database queries. In SQL, RIGHT JOIN (also known as RIGHT OUTER JOIN) is crucial for handling data effectively. This article is a beginner-friendly guide to the SQL RIGHT JOIN, an essential technique for merging different data tables. We'll walk you through the specifics of RIGHT JOIN, explaining how it stands apart from other join types in managing data.

5 Easy SQL INNER JOIN Examples for Beginners

Looking for a clear explanation of joins in SQL? Check out these five SQL INNER JOIN examples! In SQL, INNER JOINs can be a bit difficult for beginners to master. But once you start working with them, you’ll learn they’re very useful! Let’s discuss five examples of SQL INNER JOINs. But first, let’s do a quick review of why JOINs matter. In relational databases, data is organized and stored within tables.

What Is FULL JOIN in SQL? An Explanation with 4 Examples

What is FULL JOIN – one of the often neglected SQL join types? In this article, we’ll show you how useful FULL JOIN  can be and teach you how to apply it to different scenarios. The four examples cover some of the typical uses. An SQL join is a construction for combining data from two or more tables. FULL JOIN is one of the types of joins. You’ll get the most from this article if you’re already familiar with SQL joins and how they work.

SQL Joins: 12 Practice Questions with Detailed Answers

In this article, we dig into our SQL JOINS course and give you 12 join exercises to solve. But don’t worry – all the exercises have solutions and explanations. If you get stuck, help is there! This is, after all, made for practicing and learning.  SQL joins can be tricky. It’s not just the syntax, but also knowing what joins to use in what scenarios. Joins are used when combining data from two or more tables in SQL.

What Is a LEFT OUTER JOIN in SQL? 4 Practical Examples

Today’s article will discuss the LEFT OUTER JOIN in SQL. We’ll go through several examples of LEFT OUTER JOIN usage and compare it with INNER JOIN. A JOIN is an SQL feature that allows you to combine data from two or more tables. The nature of relational databases makes JOIN one of the most commonly used features in SQL. Why? In practice, you’ll very seldom have all the required data in one table.

SQL JOIN Topics That Require Practice

Are you interested in learning how to join tables in SQL? Where do you start? Many JOIN topics require practice. In this article, we’ll explore these topics by writing codes to solve real-life situations. Hopefully, you will learn which JOIN topics require attention. To make it easier for you, the topics are divided into beginner, intermediate, and advanced. Joining two or more tables in SQL lifts data analysis to another level.

How to JOIN Tables in SQL

Do you need to display data stored in different tables? Then it’s time to use SQL JOINs! This can be a challenging topic for beginners, so I’ve prepared this comprehensive step-by-step guide on joining tables in SQL. Often, the information that you want to display is stored in several tables. In such cases, you’ll need to join these tables by specifying which rows should be combined with other rows. That’s exactly what JOIN does.

SQL JOIN Tips for Beginners

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.

What Is an SQL INNER JOIN?

How do you combine data from different tables in one query? An SQL feature called JOIN is the most common operator used to create complex queries. Learn the basics in this article. SQL allows us to select data from more than one table. In fact, the whole idea of using relational databases is selecting data from related tables. And we can use SQL’s JOIN operator to do this. There are many types of JOINs in SQL.

SQL JOIN Types Explained

What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN in SQL? When should you use each one? We’ve got your answers right here. You want to combine data from two or more different tables, but you’re not sure how to do it in SQL. No worries. In this article, I will show you how to use the SQL JOIN clause to merge data from two tables.

How to Join Two Tables in SQL

Querying data from multiple tables is very common when working with relational databases. It is not difficult if you know how to use the dedicated SQL operators for doing this. In this article, you will learn how to join two tables by using WHERE and by using a special operator JOIN, and you will see how to filter rows in the result set. If you want to practice joining tables in SQL, check out our interactive SQL JOINs course.

How to Practice SQL JOINs

Updated on: November 7, 2023 There is no better way to learn how to practice SQL joins than through hands-on experience. However, there will probably be obstacles along the way. I’ll cover some of these obstacles and give ideas for how to overcome them. While this article won’t turn you into SQL JOINs expert, it will show you how to become one. So, let’s start! Diving into the world of databases?

Converting Subqueries to Joins

Not all queries are alike, especially in terms of performance. In this article, we'll look at how you can convert SQL subqueries to joins for improved efficiency. When should I use SQL subqueries? Great question! Unfortunately, there's no concrete answer. SQL beginners tend to overuse subqueries. Typically, once they find that SQL construction works in one situation, they try to apply that same approach to other situations. It's only natural.

SQL Hacks To Control Family Budget On Black Friday Weekend

If you’re in the US, chances are you’ve been eagerly awaiting the approach of Black Friday just as much as Thanksgiving. Though the shopping frenzy takes hold of nearly everyone, some people have to stick to their budgets and shop prudently. In this article, we’ll take a look at how generating an SQL report can help you track how much your family spent shopping on Black Friday. Storing Black Friday Purchases in a Database Before we can create an SQL report, we first need some data we can use.

An Illustrated Guide to Multiple Join

So far, our articles in the "An Illustrated Guide" series have explained several join types: INNER JOINs, OUTER JOINs (LEFT JOIN, RIGHT JOIN, FULL JOIN), CROSS JOIN, self-join and non-equi join. In this final article of the series, we show you how to create SQL queries that match data from multiple tables using one or more join types. Join Types in SQL Queries Before we start discussing example SQL queries that use multiple join types, let's do a short recap of the join types we've covered so far, just to be sure you understand the differences.

An Illustrated Guide to the SQL Non Equi Join

Did you know that in SQL, a join doesn’t have to be based on identical matches? In this post, we look at the SQL non equi join, which uses ‘non-equal’ operators to match records. We’ve already discussed several types of joins, including self joins and CROSS JOIN, INNER JOIN and OUTER JOIN. These types of joins typically appear with the equals sign (=). However, some joins use conditions other than the equals (=) sign.

An Illustrated Guide to the SQL Self Join

What is an SQL self join and how does it work? When should it be used? We’ll provide answers to those questions! In SQL, we can combine data from multiple tables by using a JOIN operator. JOIN has several variants; we’ve already discussed CROSS JOIN, INNER JOIN, and OUTER JOIN. Most of the time, these operators join data from two or more different tables. You can practice all the different types of JOINs in our interactive SQL JOINs course.

How to Track Down Duplicate Values in a Table

When it comes to information management, duplicates present one of the most common challenges to data quality. In this article, I'll explain how it is possible to find and distinguish duplicate names with the help of the SQL data programming language. I really like my maiden name. The reason I like it so much is because it's rare. My maiden name (first with last) provided a unique identifier on platforms such as LinkedIn, Facebook, Twitter and similar.

An Illustrated Guide to the SQL OUTER JOIN

We’ve already discussed the SQL CROSS JOIN and INNER JOIN statements. It’s time to explore another: OUTER JOIN. What is it? How does it work? Let’s find out! If you’ve read our other posts, you know that you can link the data in two or more database tables using one of the many types of SQL join operator. Today, we’ll discuss the three kinds of OUTER JOIN: LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN.

An Illustrated Guide to the SQL INNER JOIN

What is an SQL INNER JOIN, and how does it work? Let's find out! In my last article, I discussed the CROSS JOIN operation in SQL. Today, we'll look at INNER JOIN and how to use it. Is it the same as a JOIN? How many tables can you link with an INNER JOIN? These are all good questions. Let's look at the answers! What is an INNER JOIN?

An Illustrated Guide to the SQL CROSS JOIN

What is an SQL CROSS JOIN statement? When should you use it? When shouldn't you use it? This post will tell you what you need to know about CROSS JOIN. You already know that you can use the SQL JOIN statement to join one or more tables that share a matching record. And if you're read the LearnSQL's post Learning SQL JOINs Using Real Life Situations, you know that there are many types of JOINs.

An Introduction to Using SQL Aggregate Functions with JOINs

Previously, we've discussed the use of SQL aggregate functions with the GROUP BY statement. Regular readers of the our blog will also remember our recent tutorial about JOINs. If you're a bit rusty on either subject, I encourage you to review them before continuing this article. That's because we will dig further into aggregate functions by pairing them with JOINs. This duo unleashes the full possibilities of SQL aggregate functions and allows us to perform computations on multiple tables in a single query.

Learning JOINs With Real World SQL Examples

The JOIN statement lets you work with data stored in multiple tables. In this article, I’ll walk you through the topic of JOIN clauses using real world SQL examples. Imagine if you could only work with one database table at a time. Fortunately, this isn’t anything we have to worry about. Once you learn the JOIN statement, you can start linking data together. In this article, I’ll use real world SQL examples that illustrate how we use JOINs, how each type of JOIN works, and when to use each type.

SQL JOINs Explained with Venn Diagrams

A SQL JOIN is a method to retrieve data from two or more database tables. This article presents a basic overview of what data from a particular SQL join will look like. A popular way of understanding SQL joins is to visualize them using Venn diagrams, so each example have corresponding Venn diagram, appropriate SELECT statement and the result table. There are a few major kinds of SQL joins:

SQL JOINs for Beginners

You’re probably already familiar with simple SQL queries, such as SELECT * FROM table. Now you are wondering what to do when you have multiple tables, and you want to join them. Exactly! JOIN is the key. In this SQL JOINs tutorial for beginners, you will learn how to connect data from multiple tables. What are SQL JOINs? Databases usually have more than one table. JOINs are an SQL construction used to join data from two or more tables.

Tag: Joins

What Is CROSS JOIN in SQL?

What is a CROSS JOIN in SQL, and when should you use it? We answer those questions – and give you some examples of CROSS JOIN you can practice for yourself – in this article. Imagine you're looking through your wardrobe for outfit ideas, wondering which top to wear with which bottom. When you think of the perfect outfit, you envision all of the tops and bottoms in your closet combined.

Your Complete Guide to SQL JOINs (with Resources)

This detailed guide covers all important SQL JOIN topics, from basic concepts to advanced techniques. Bookmark this guide for future reference – it’s packed with useful resources and guides to help you work with JOINs effectively. SQL JOINs are essential in SQL and data analysis, as they let you combine data from different tables into a unified view. In this article, I've gathered everything you need to know about SQL JOINs.

5 Easy SQL INNER JOIN Examples for Beginners

Looking for a clear explanation of joins in SQL? Check out these five SQL INNER JOIN examples! In SQL, INNER JOINs can be a bit difficult for beginners to master. But once you start working with them, you’ll learn they’re very useful! Let’s discuss five examples of SQL INNER JOINs. But first, let’s do a quick review of why JOINs matter. In relational databases, data is organized and stored within tables.

What Is FULL JOIN in SQL? An Explanation with 4 Examples

What is FULL JOIN – one of the often neglected SQL join types? In this article, we’ll show you how useful FULL JOIN  can be and teach you how to apply it to different scenarios. The four examples cover some of the typical uses. An SQL join is a construction for combining data from two or more tables. FULL JOIN is one of the types of joins. You’ll get the most from this article if you’re already familiar with SQL joins and how they work.

SQL Joins: 12 Practice Questions with Detailed Answers

In this article, we dig into our SQL JOINS course and give you 12 join exercises to solve. But don’t worry – all the exercises have solutions and explanations. If you get stuck, help is there! This is, after all, made for practicing and learning.  SQL joins can be tricky. It’s not just the syntax, but also knowing what joins to use in what scenarios. Joins are used when combining data from two or more tables in SQL.

How to Write Multiple Joins in One SQL Query

Have you ever wondered how multiple joins work? Want to know how to join multiple tables in one query? Read this article to find out! If you are just beginning your SQL journey, you may have found it difficult to understand the concept of SQL JOINs, especially if you have to join more than two tables in one query. Worry not! In this article, we will explore how JOIN works and solve all its mysteries!

What Is the OUTER JOIN in SQL?

Even if you are new to SQL, you must have come across the term OUTER JOIN. In this article, I will explain what OUTER JOIN in SQL does. I’ll use some practical examples to demonstrate how it is used in day-to-day SQL applications. If you want to use SQL for practical purposes, learning the different JOINs is extremely important. In fact, you will be using a JOIN in just about every second query you write.

5 Best Practices for Writing SQL JOINs

These best practices for SQL JOINs will help you make readable SQL queries that deliver accurate, clear, and understandable output. Considering that relational databases are built around related tables, it’s no wonder that SQL JOINs – which allow you to combine information from multiple tables – are one of the primary skills acquired by SQL newbies. SQL JOINs course by LearnSQL.com is the perfect place to refresh your knowledge about JOINs.

How to Join Only the First Row in SQL

In your projects, you may encounter situations when you have many orders corresponding to one customer or many temperature observations corresponding to the same location, but you only need to join the first row with the most recent order or the most recently observed temperature to the corresponding record in another table. In this article, I’ll go through several ways to do this in SQL. The best way to practice basic and advanced SQL is our interactive SQL Practice Set course.

Best Places to Practice SQL JOINs Online

You’ve just started your journey with SQL and you’re not sure what a JOIN is or where to use it. Don’t worry! In this article, you will find out what JOINs are and where you can practice them online. If you have just started learning SQL, you have a lot of topics to cover before you can call yourself a data professional. If you are serious about using SQL, you’ll have to understand JOIN – what it does, when you can use it, and what its different variants do.

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. Table of Contents Introduction to JOIN INNER JOIN Example #1: Showing books and their authors Example #2: Showing books and their translators LEFT JOIN Example #3: Showing all books alongside their authors and translators, if they exist Example #4: Showing all books with their editors, if any RIGHT JOIN Example #5: Books and editors with RIGHT JOIN FULL JOIN Example #6: Showing all books and all editors Example #7: Showing all books, authors, editors, and translators Time to Practice SQL JOINs!

What Is a Self Join in SQL? Explaned With 7 Examples

The self join is a popular special case of the SQL JOIN. While most JOINs link two or more tables with each other to present their data together, a self join links a table to itself. This is usually done by joining a table to itself just once within a SQL query, but it is possible to do so multiple times within the same query. Typically, each table in a database stores a specific type of information.

How to Join the Same Table Twice

JOIN is one of the most common statements in SQL. As you may know, it is used to join and combine data from two or more tables into one common data set. In this article, I’m going to discuss special types of joins? in which you combine the same table twice—including joining a table to itself, also known as the self join. When and why do you need to do this?

SQL JOIN Cheat Sheet

Ready to master SQL JOINs? Get your downloadable cheat sheet now! Your shortcut to becoming an SQL JOINs expert is one click away. Dive deep into the world of SQL JOINs with our detailed SQL JOIN Cheat Sheet, a must-have resource for data enthusiasts at every level. Whether you are just starting out or looking to sharpen your skills, this guide is tailored to provide you with the quick reference needed to use SQL JOINs efficiently.

Can you Join two Tables Without a Common Column?

Yes, you can! The longer answer is yes, there are a few ways to combine two tables without a common column, including CROSS JOIN (Cartesian product) and UNION. The latter is technically not a join but can be handy for merging tables in SQL. In this article, I’ll guide you through the different solutions with examples. When Do you Need to Join Tables Without a Common Column? Beginners just getting started with SQL are usually introduced to standard equi joins, in which two tables are combined by a common column.

What's the Difference Between Multiple Tables in FROM and Using JOIN?

What’s your approach to joining tables in SQL? In this article, we discuss two approaches and explain why many SQL developers have a definite preference for JOIN. Do you prefer to list multiple tables in FROM and use WHERE to set the join conditions? Or do you use the JOIN keyword? SQL supports both, but there are significant differences between them. Let’s look at each one in detail and then discuss why JOIN is generally preferred.

Practical Examples of When to Use Non-Equi JOINs in SQL

If you think that two tables in SQL can be joined only using the common field, you will be excited to learn that there are other ways of joining. Non-equi JOINs use different kinds of comparison operators in the JOIN condition. In this article, I’ll guide you through non-equi JOIN examples to show the common use cases for this type of JOIN. Equi JOIN vs. Non-Equi JOIN How do you usually join two tables in SQL?

How to Learn SQL JOINs

JOINs are one of the most fundamental and commonly used SQL commands for manipulating and querying real-world data sets. They are also one of the more challenging SQL topics to master! In this article, you’ll learn an effective strategy to learn the different types of SQL JOINs. When data is stored in a single table, we can easily retrieve rows and get all the information we need. But when businesses scale, so does their data.

Subquery vs. JOIN

One of the challenges in writing SQL queries is choosing whether to use a subquery or a JOIN. There are many situations in which a JOIN is the better solution, and there are others where a subquery is better. Let’s consider this topic in detail. Subqueries are used in complex SQL queries. Usually, there is a main outer query and one or more subqueries nested within the outer query.

How to Join 3 Tables (or More) in SQL

Updated on: April 19, 2024 Using JOIN in SQL doesn’t mean you can only join two tables. You can join 3, 4, or even more! The possibilities are limitless. The best way to practice SQL JOINs is LearnSQL.com's interactive SQL JOINs course. It contains over 90 hands-on exercises that let you refresh your SQL JOINs knowledge. It covers a wide range of topics from simple 2-table JOINs, through joining multiple tables and using OUTER JOINs, to joining a table with itself.

How to LEFT JOIN Multiple Tables in SQL

Can you LEFT JOIN three tables in SQL? Yes, indeed! You can use multiple LEFT JOINs in one query if needed for your analysis. In this article, I will go through some examples to demonstrate how to LEFT JOIN multiple tables in SQL and how to avoid some common pitfalls when doing so. The best way to practice different types of joins is our interactive SQL JOINs course. It contains over 90 hands-on exercises that cover simple 2-table joins, joining multiple tables, LEFT JOIN, FULL JOIN, and many more.

Tag: Keys

Why Use Primary Keys and Foreign Keys in Databases?

Relational databases organize data in a standardized manner. All data is entered into tables, the so-called relations. The tables are linked with one another to create connections between the data. The backbone of any relational database is the primary and foreign keys. Read along to find out why they are so important. In this article, we focus on the reasons why relational databases use primary and foreign keys. First, we review what primary and foreign keys are.

Tag: Kurtosis

High Performance Statistical Queries –Skewness and Kurtosis

In descriptive statistics, the first four population moments include center, spread, skewness, and kurtosis or peakedness of a distribution. In this article, I am explaining the third and fourth population moments, the skewness and the kurtosis, and how to calculate them. Mean uses the values on the first degree in the calculation; therefore, it is the first population moment. Standard deviation uses the squared values and is therefore the second population moment.

Tag: Language

What Programming Language Should You Learn?

If you've ever been wondering which programming language you should learn first, you know that's a tough nut to crack. It’s especially difficult if you are new to IT and programming. In this article, I give suggestions for what to learn first and what perspectives each language can give you in IT. There are hundreds of programming languages, and new ones are showing up all the time. Getting to know all of them is simply impractical and impossible.

Tag: Learn Sql

SQL LEAD Function

Get to know the SQL LEAD function, an important function to know for anyone working with SQL in data analysis. Learn through examples how to use this function in practice. The SQL LEAD function is a very important and useful SQL window function. SQL window functions are essential for doing efficient data analysis. They allow you to work with groups of rows and single rows at the same time. They make writing complex reports easier.

SQL Track of the Season: SQL from A to Z in MySQL

Do you feel the spring already? Everything is in full bloom at this time of the year. Why shouldn’t it be the same with your career? You just need to water it with a new skill. Here is the brilliant SQL from A to Z in MySQL track, our Track of the Season. In this article, I answer common questions about this awesome set of online MySQL courses. Why should you care about relational databases at all?

Your Guide to SQL Practice at LearnSQL.com

Explore a variety of SQL practice opportunities at LearnSQL.com and take your data analysis skills to the next level. Whether you're a beginner or an advanced user, our learning resources are designed to help you master SQL through hands-on learning and real-world usage scenarios. SQL, or Structured Query Language, is a powerful tool used extensively in data analysis. It allows you to access and manipulate databases quickly and efficiently. Whether you are working in finance, healthcare, tech, or almost any other industry, SQL helps you extract and analyze data.

Does Data Analytics Require Coding

Thinking about a future in data analytics? You might be pondering the need for coding skills. Is it necessary to be good at programming? As the worlds of data analytics, technology, and data science merge, the importance of coding becomes clearer. It’s crucial to understand which programming languages are key and how much expertise you need, making the journey into this vibrant field less daunting. In this article, we're going to focus on the importance of coding, particularly SQL, for data analytics.

In-Person vs Online SQL Training for Data Analytics

If you want to become a data analyst, you’ll have to choose between in-person and online SQL training. Learn the pros and cons of each path in this article. Want to become a data analyst? First, you have to decide which learning method to choose – traditional, in-person classes or online courses. Technology has given us more options, leading to questions about the best fit for different learning styles and goals.

20 SQL Practice Problems for Beginner and Intermediate Users

Want to become an SQL expert? Try solving those 20 SQL practice problems! Whether you're just starting your SQL journey or preparing for exams, you need to sharpen your SQL skills if you want to become an expert. And you know what people say: practice makes perfect! Like most skills, SQL is best learned through experience; practicing SQL allows you to apply your knowledge to real-world scenarios. Through repeated practice, you'll gain the confidence to dive into complex SQL tasks and excel in both academic and professional fields.

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.

The Best Online SQL Editors

When it comes to online SQL editors, you have lots of options. Find out what features you should look for and what editors we prefer in this article. In this article, I'm going to share my insights on online SQL editors. These handy web-based tools have made my SQL query execution and database management tasks much simpler and more accessible – especially when compared to traditional desktop software. I'll discuss their key features and offer guidance on choosing the right one for different needs, whether you're a beginner or an experienced user.

18 SQL Questions for Beginners: Theory and Practice

Whether you're starting or refreshing your SQL skills, join us as we work through these 18 SQL practice questions for beginners. SQL, or Structured Query Language, is a programming language used to define, retrieve, and manipulate data in relational databases. It provides an intuitive syntax of SQL statements and keywords that create, modify, and query relational databases. This article focuses on reviewing and practicing the basics of SQL. We’ll start by reviewing the SELECT statement and its required and optional components for fetching data from a single table.

SQL CASE WHEN Explained: 10 Easy Examples for Beginners

The CASE WHEN statement lets us make decisions on our data, categorizing and manipulating records based on specified conditions. Find out how to use CASE WHEN in this article. Imagine you're deciding what to wear for the day. You take out your umbrella if it's raining; if not, you leave it at home. This decision-making procedure is essentially the same as a SQL CASE WHEN statement. In the realm of SQL, the CASE WHEN statement functions much like an if-then-else expression, allowing us to create custom classifications within a query.

Data Export: From SQL Query to Spreadsheet

How do you export data from an SQL database to Excel or another spreadsheet? In this article, I’ll look at various methods and share a few tips for when things go wrong. SQL is the most widely used method of extracting data from a database. However, it’s not the only gadget in an analyst’s toolbox. Once the information is extracted, you’ll often want to import it into a spreadsheet – maybe to do further analysis or just to make it look pretty so you can present it to management.

Using SQL in Data Warehousing

SQL is a key player in organizing and analyzing data in data warehouses. In this article, I'll introduce you to the basics of SQL in data warehousing. We’ll learn how this powerful language helps manage large datasets, making your work easier and more productive. Whether you're a student diving into the world of technology or an experienced specialist navigating the domain of data, understanding the concept of data warehousing is fundamental.

Analyzing Social Media Data with SQL

Diving into the world of SQL social media analysis? This guide will help you start using SQL to analyze and interpret data from social media platforms. Get ready to transform your approach to digital data and unlock new possibilities in social media analytics! Welcome to the exciting world of SQL and social media analysis! If you're new to this field, you're about to discover how powerful a tool SQL can be in understanding the vast sea of data generated on social media platforms every day.

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.

SQL for Human Resources

Data is just as important in Human Resources as it is in other business areas. That makes SQL for HR more than just a tool; it's a game-changer. Let's dive into this transformative journey together. In the modern business world, data has become a cornerstone. It drives decisions, shapes strategies, and offers insights that were previously out of reach. Every corner of an organization, every department, is tapping into the potential of data to enhance its operations.

SQL Practice for Students: 11 Exercises with Solutions

Calling all students! Are you SQL-curious? Want to learn or improve your SQL skills? This article has 11 SQL practice exercises with detailed solutions. Have you ever heard that “Practice makes perfect”? You probably have – that’s why you’re looking for SQL practice resources. If you want to develop strong skills or become an expert in a certain domain, you have to practice. As Rebecca McKeown wrote in her outstanding article Learning SQL?

Where to Practice SQL

Are you looking to boost your data management or analytical abilities? Then you need to know how and where to practice SQL, the worldwide language for managing and running relational databases. Of course, knowing where to practice SQL can be a challenge – there are so many options! In this article, we’ll walk you through the best digital platforms for enhancing your SQL skills. SQL, or Structured Query Language, is the universal language for managing and operating relational databases.

Why Learn SQL?

In a world overflowing with data, SQL is the key to making sense of it all. It's the bridge between raw numbers and meaningful insights. In this article, I'll explore SQL’s unmatched value in our data-centric era. Let's answer the question: "Why learn SQL?" Every day, businesses and individuals generate and interact with vast amounts of data, seeking insights and solutions. Amidst this data-driven environment, a pressing question arises: Why learn SQL?

How to Prepare for the SQL Assessment Test

In this guide, I’ll walk you through the essentials of SQL assessment preparation, from understanding database management to mastering data analysis and SQL commands. Let’s dive in and set you on the path to success. In today's data-centric world, mastering SQL proficiency holds paramount importance. Whether you're a seasoned database manager or a newbie exploring the realm of database management, gearing up for an SQL Assessment is crucial. Stepping into the world of SQL can be both thrilling and challenging.

This Is the Best SQL Assessment to Boost Your Career

What’s an SQL assessment and why would you need one? Where can you find a free and reliable gauge of your SQL skills? Find out in this article. In today's data-driven world, proficiency in SQL is more than just a skill—it's necessary. Whether you're looking to explore and analyze data to derive actionable insights or to store, manage, and optimize data in a relational database, having a solid foundation in SQL can significantly boost your resume.

How to Create Your Own Database to Practice SQL

Welcome to the step-by-step guide to creating your own SQL database from scratch, designed with beginners in mind. This guide not only helps you set up your database but also introduces you to essential SQL practice exercises to get you started on your learning journey. Follow along to gain SQL hands-on practice and foster a deeper understanding of SQL functionalities. Set a solid foundation for more advanced SQL training!

How SQL for Business Can Boost Profit and Effectiveness

Are you ready to unleash the power of SQL and transform your business? In this article, we'll look at all of the ways SQL can improve your company's performance, from decision-making capabilities to operational efficiency. Having the correct tools to traverse the sea of information is critical in today's data-driven corporate climate. Structured Query Language, or SQL, is an essential tool for this task—and it’s one that has endured the test of time.

Free Course of the Month: Blog & Traffic Data

Why practice SQL with real-life scenarios? We'll explain in this article – and we’ll show how you can do it for free during October 2023 with this LearnSQL.com course! SQL is the backbone of many data-driven applications and businesses. It's a powerful language that allows you to interact with databases, retrieve data, and make insightful decisions. If you're looking to improve your SQL skills, our Basic SQL Practice: Blog & Traffic Data course is the perfect opportunity.

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.

How SQL Can Help You Understand Your Clients Better

In this article, we will delve into how SQL can help businesses analyze customer data, uncover patterns, and make informed decisions to meet their clients' needs. Managing and understanding clients is crucial for any business, and this requires data. Client data, such as purchasing habits, preferences, and feedback, is typically stored in databases. To access and analyze this data, you need to be proficient in SQL, the language designed for managing and querying data in databases.

SQL for Project Managers: Enhancing Decision-Making

Did you know that SQL is a vital component in the project manager’s toolkit? In this article, we'll delve into how SQL for project managers enhances their workflow, promotes informed decision-making, and boosts operational efficiency. Data has become the foundation of decision-making across industries. In today's data-driven world, it's critical to arm yourself with the correct tools for dealing with the influx of data. One such tool that has stood the test of time is Structured Query Language, better known as SQL.

An SQL Basics Primer for Non-IT Professionals

You don’t need to be an IT professional to understand SQL. Our quick primer of SQL basics is perfect for beginners without any computer science or programming background. If you’ve ever tried to learn a new software program, you know it takes more than just a few minutes. But it doesn’t mean you can’t learn it! The same is true if you want to learn SQL and databases. Even if you don’t have an IT background, you can do it.

How SQL Helps the Healthcare Sector

Why does the healthcare industry need SQL? Find out how you can use SQL for healthcare in this article. The digital age has ushered in a new era where data is at the heart of every industry. From finance to retail, data drives decision-making and strategy, shaping the way businesses operate and grow. The healthcare sector, with its vast and complex data sets, is no exception to this trend. The rise of digital health records, patient databases, and common integration of hospital inventory management software has underscored the importance of efficient data management in healthcare.

New Feature: Notebook to Boost Your SQL Learning

You want to learn SQL effectively but you keep forgetting queries? Now you can use  LearnSQL.com’s new notebook feature in all our courses! This new tool will help you memorize and recall content. I remember when I first started to learn SQL. I was moving quite smoothly through most of the lessons, taking a lot of notes in my paper notebook. (I have a lot of old school paper notebooks).

Best SQL Books for Data Analysis

In the world of data analysis, SQL is a powerful tool. It's a language that helps professionals find, organize, and analyze the data stored in databases. If you're looking to learn this important skill, you've come to the right place. This article will guide you through the best SQL books for data analysis, whether you're just starting out or already have some experience. SQL (Structured Query Language) is a standard language used for working with databases.

The Best Way to Learn SQL: A Complete Guide for Beginners

If you've ever wondered about the best way to learn SQL, you're in the right place. Whether you're a complete beginner or an experienced professional looking to upskill, this comprehensive guide will show you the way. In today's data-driven world, you can think of data as a treasure chest full of gold. And SQL (Structured Query Language) is your personal key to unlocking it. SQL is a potent tool that allows you to communicate with databases, enabling you to extract, shape, and make sense of data.

How to Master SQL

You've heard SQL is a must-have skill for furthering your career. You want to learn it. In this article, we look at why it is so beneficial to master SQL and how you can reach that level of mastery. Master SQL, and unlock the power of relational databases, the most used databases for managing structured data. But what makes SQL so important? SQL, or Structured Query Language, is a must-have skill for anybody navigating today's data-driven world.

Google BigQuery SQL Syntax: A Comprehensive Guide

What is Google BigQuery? What can it do for your organization? Is BigQuery SQL a valuable skill? Where can you learn it, and where can you get some practice? Very few organizations today are not computerized. Many processes now make use of the IoT (Internet of Things), where all kinds of devices are networked and continually feed real time data into computer systems. The result is a vast amount of data available for decision-making.

Our New Interactive Course – SQL Practice: University

Are you a beginner looking for a hands-on online SQL course to solidify your skills? Or perhaps you're an SQL learner hungry for real-world applications of your new skills? LearnSQL.com, has crafted a robust practice-based learning experience to help you advance at your own pace. Here is SQL Practice: University! In today's data-driven world, mastering SQL is more than just a useful skill—it's a powerful tool that can open doors to many career opportunities.

How E-Commerce Businesses Can Benefit From SQL

Learn how SQL for e-commerce can empower your online business. When we talk about business in the modern age, the phrase "knowledge is power" takes on a whole new dimension. In the world of e-commerce, the real power lies in the ability to leverage data; one of the key tools in the arsenal of data management and analysis is SQL. SQL, or Structured Query Language, is essential for e-commerce businesses looking to extract valuable insights from their vast reserves of data.

Course of the Month: INSERT, UPDATE, and DELETE in PostgreSQL

Do you want to be a data engineer or data analyst? Do you work with databases daily and need to expand your skills with the basics of data manipulation? You've come to the right place. For June 2023, our SQL course of the month is PostgreSQL INSERT, UPDATE, and DELETE Commands! Learn SQL for FREE! How do you get this free PostgreSQL course in June? Create a free LearnSQL.

Why Do You Need SQL to Work With Google BigQuery?

Data is just as important to your business as investing or accounting; that’s why many people use Google’s BigQuery data warehouse. In this article, we'll discuss why you should learn SQL if you want to start using BigQuery. Unleash the power of your data! In the ever-growing landscape of data-driven decisions, organizations are continuously on the lookout for tools that can help them handle and analyze their data efficiently. Enter Google BigQuery: a powerful, Cloud-based data warehouse designed to store and analyze massive datasets in record time.

How to Use SUM() with GROUP BY: A Guide with 8 Examples

Explore some real-world examples of using SUM() and GROUP BY in SQL, from the most basic to the most sophisticated. SUM() is a SQL aggregate function that computes the sum of the given values. GROUP BY is a SQL clause that partitions rows into groups and computes a stated aggregate function for each group. Using these two functions together, you can compute total sums for a group of rows. In this article, we’ll see 8 different examples of how you can combine SUM() and GROUP BY to create many different reports.

The Best Database Books You Should Read Now

So, you're interested in databases and looking for some database book recommendations. In this article, we’ll take a look at our top database book recommendations to feed your brain. In essence, databases are like digital filing cabinets. They have the ability to organize, store, and retrieve data. Large amounts of data are stored, managed, and made easily accessible by using databases. Additionally, databases make it possible for data to be organized into tables, which makes searching and sorting easier.

How to Learn SQL Without Any Programming Knowledge

If you think that learning SQL is only for programmers, you are deeply wrong. This skill is totally within your grasp! SQL is not just popular and in demand; it’s also quite easy and intuitive to learn. Read on to find out more! You’re searching for inspiration on how to start learning SQL. Maybe you want to change your job, or want to become more competitive in the job market.

The Most Important SQL Commands

In this article, we'll explore the most common SQL commands that everyone should know, including SELECT, INSERT, WHERE and more. We’ll also give examples of how to use each command. Are you ready to dive into the world of databases? SQL, or Structured Query Language, is a programming language that is designed specifically to interact with databases. It allows you to manipulate the data in databases in multiple ways – e.

Why SQL Is the Perfect Database Language

Which programming language should you learn if you want to work with databases? We’ll explain why SQL is the top choice! Learning a database language can be an incredibly valuable skill in today's data-driven world. But with so many options out there, it can be difficult to know where to start. In this article, we'll make a compelling case for why SQL is the ideal choice for anyone looking to dive into the world of databases.

10 Beginner SQL Practice Exercises With Solutions

Solve these ten SQL practice problems and test where you stand with your SQL knowledge! This article is all about SQL practice. It’s the best way to learn SQL. We show you ten SQL practice exercises where you need to apply essential SQL concepts. If you’re an SQL rookie, no need to worry – these examples are for beginners. Use them as a practice or a way to learn new SQL concepts.

The Best SQL Blogs to Follow

In this article, you’ll find a list of the best SQL blogs and why they’re worth checking out. SQL (short for Structured Query Language) has been around since the 1970s. It’s still a wildly popular coding language. It is based on the idea that data can be structured and built through relations. If you’re familiar with SQL, you’ve likely heard the term “relational database.” This means that the tables of the database have pre-defined relationships between them: One field in one table will match another field in another table.

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.

Best MySQL Courses for Beginners

SQL is among the most important languages when it comes to dealing with huge amounts of data. If your job includes analyzing or collecting data and you feel that an Excel file is not enough, you need to learn or develop your SQL skills. And if you learn SQL, you also need to know one of its most popular dialects - MySQL. If you've made the decision to learn SQL, you've come to the right place.

Learning SQL in Your Native Language is Finally Possible

Updated on: April 21, 2024 Do you or someone you know speak English as a second language? Would you like to learn SQL online in your preferred language? Good news! Our awesome SQL courses are now available in French, Spanish, German, Italian, and Portuguese! SQL, or Structured Query Language, is a programming language used for managing and manipulating data in databases. It's an essential skill for anyone working with data, whether you're a data analyst, a software developer, or just someone who wants to understand how databases work.

The Best Apps to Learn SQL

Updated on: April 23, 2024 Let us guide you to the best apps for learning SQL on the go. They are designed to seamlessly integrate into your busy lifestyle – ensuring you develop your database skills anytime, anywhere. Are you eager to dive into SQL but unsure where to start? This article is your ultimate guide to the top apps for learning SQL. We include suggestions tailored for users of all levels, from beginners to advanced learners.

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.

Data Cleaning in SQL

Data cleaning is an important part of any data analysis. Here we’ll discuss techniques you can use to do data cleaning in SQL. I find it nearly impossible to focus on work when my desk is a mess. If it’s cluttered with paper, coffee mugs, or random toys my daughter has somehow snuck into my office, there is no chance I will be able to get anything done until my desk is back in order.

Free Course of the Month – PostgreSQL JOINs

Our PostgreSQL JOINs course will help you consolidate your knowledge of working with data from two or more tables in a PostgreSQL database. Throughout the month of February 2023, this awesome SQL course is absolutely FREE! Wondering why we want to give you this SQL course for free? We've been doing this for a long time. Every month, we choose one of our interactive online SQL courses and give users free access to it.

How to Group by Multiple Columns in SQL

When analyzing large data sets, you often create groupings and apply aggregate functions to find totals or averages. In these cases, using the GROUP BY clause with multiple columns unfolds its full potential. GROUP BY is a clause of the SELECT command. It allows you to compute various statistics for a group of rows. For example, you can use GROUP BY with an employee table to know how many employees are of each gender.

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.

Is SQL Hard to Learn?

If you have no IT skills, how hard is it to learn SQL? Will it be too technical for you? Is it worth the effort? And where would you start? In this  article I will answer those questions. As an IT consultant and trainer, I've often advised people to learn SQL. And, almost as often the reply has been, "Is it hard to learn SQL? Do I need technical or IT skills to learn it?

SQL Books for Beginners

How can you learn SQL more efficiently? Besides a good online course, find an interesting book to enrich your knowledge. Here are the best SQL books for beginners. SQL, or Structured Query Language, is a very powerful tool to work with many types of data. If you are interested in learning SQL you probably know how useful it is, and how widely it is needed. To learn SQL successfully, a solid online course for beginners like our SQL Basics is a great start.

The Future of SQL

Is it worthwhile to learn SQL? Or will a language that’s over 40 years old soon be outdated? Have relational databases been eclipsed by the advent of other database solutions like NoSQL? In this article, we answer these questions. Do you need to upgrade your IT skills? What should you learn first? The choice is daunting. If you're looking to the future, you obviously want to invest your time in something that's still widely used and will continue to be in the years to come.

What Are the Basic SQL Queries?

You can access the data in a database using some basic SQL queries. In this article, we review the fundamentals SQL queries every beginner should know. Databases are everywhere, and they contain different kinds of data. Almost all of them support SQL, a language that lets you read and manipulate the data inside a database. In this article, I’ll show you the basic SQL queries that you can use to perform many common everyday data tasks.

SQL Beginners: Questions to Ask Before Writing a Query

SQL is known for its easy-to-follow syntax that even beginners can understand pretty quickly. Still, to write your own SQL queries, you need to know the basics. Let’s explore what things need to be considered before writing a SQL query. If you are looking for a career in data analysis or just want to work effectively and independently with data in any analytical position, you’ll need to master SQL. Luckily, this programming language is beginner-friendly and can be learned just in a few months with the right learning sources.

SQL Courses for Software Testers

In this article, you will learn why software testers need SQL and which courses are ideal for them to learn it. Do software testers need SQL? Oh yes, they do! They don’t necessarily use it all the time or take advantage of all its possible features. But a tool for accessing data in a database is essential for a software tester. And SQL is exactly that: a programming language designed specifically for handling data in relational databases.

How the WITH Clause Works in SQL

Do you want to master complex SQL queries? Learn how to use the powerful WITH clause! In SQL, there are simple queries and complex queries. A simple query can take data from a table, apply a filter, and return the data as it is in the source table. A complex query may require complex transformations to the source data or may need to read and join data from multiple tables or views.

How to Learn SQL for Marketing Analytics With LearnSQL.com

SQL is a valuable tool for any experts wanting to make data-driven decisions. Marketers are no exception. Let's explore how to design an effective learning path for SQL in marketing. SQL for marketing analytics is used to understand customers better and to increase the effectiveness of marketing campaigns. If you work in marketing and want to join other marketing experts who have already benefited from this tool, you need to learn SQL.

What's New in MS SQL Server 2022

Microsoft SQL Server 2022 is almost here! In this article, we’ll review what new enhancements and features will be coming to this popular relational database. The new version of MS SQL Server will become available almost three years after SQL Server 2019 was released. (You can learn more about the origins and different versions of SQL Server in A Brief History of MS SQL Server.) If you need to start implementing a software solution, there are plenty of changes and new features in SQL Server 2022 that makes it a great option.

How to Learn SQL

It takes quite an effort to learn SQL or any new skill for that matter. But pushing hard is not enough to learn it successfully. You can sit for hours and still feel like you're not making progress. So, what do you do? Let it go or try even harder? I say: work smart, not hard. SQL (Structured Query Language) is one of the most popular programming languages. It is an invaluable tool in a world overflowing with data.

Summer 2022 Track of the Season: Creating Database Structure

Summer is a great time to learn something new! Have you heard about data engineering? It’s one of today’s hottest skills. In this article, I'll show you why we selected our Creating Database Structures track as our SQL Track of the Season – and why it’s your ticket to a new career! LearnSQL.com offers online SQL training tracks – logically structured and well-thought-out learning paths that will help you work towards becoming an SQL expert.

PostgreSQL vs. MySQL: Is It Difficult to Switch?

So you know PostgreSQL, but the boss has decided to switch to MySQL. What are the differences between these two SQL dialects? We discuss PostgreSQL vs. MySQL in this article. PostgreSQL has gained popularity in the last decade, and many developers and database specialists learned PostgreSQL as their first SQL dialect. But PostgreSQL is not the only relational database; during your IT career, you will probably be asked to use another SQL dialect – like MySQL.

What Is an SQL Query?

An SQL query is the most basic SQL command. It is a question you ask a database. In this article, we dive into the basics of SQL queries to kickstart your SQL journey with practical knowledge right away! SQL, or Structured Query Language, is a programming language designed to interact with databases. When you want to access data in a database, be it to alter, delete, add, or simply extract information, you use SQL.

Lesser-Known SQL YouTube Channels You Need to Follow Now!

Are you learning SQL? Many beginners start with YouTube tutorials. However, popular SQL clips are not always very helpful. You need to know which ones to watch so that you don't waste your time. In this article, I discuss SQL YouTube channels that, while not the most popular, deserve your attention. Click "subscribe" and watch! Those who follow my articles on LearnSQL.com know I'm not a huge fan of learning SQL from YouTube.

How to Set Up a Corporate SQL Training Program

Are you looking to set up a business or corporate SQL training for your company's employees? In this article, we’ll discuss how to build an efficient SQL training program and why the LearnSQL.com platform is the choice of leading tech companies. If you are responsible for employees’ professional development – especially in a data-driven company – you know that SQL is essential for anyone who works with data. This programming language can enhance the performance of data and business analysts (for whom SQL is often a primary tool) as well as marketers, salespeople, HR specialists, auditors, and many more.

How to Get More from Your BI Tools with SQL

Are you frustrated with the limitations of your business analytics tool? Do you wonder if there are other features you could tap into? Would you like to know how SQL compliments your work with Power BI and Tableau? Read this article to learn more! If you are a data analyst or if data analysis is part of your everyday job, Business Intelligence (BI) tools are crucial for your work. You also know that most databases run SQL queries in the background of such tools.

Switching from PostgreSQL to MS SQL Server

What are the differences in PostgreSQL vs. MS SQL Server? We discuss the similarities and the differences between these two popular SQL dialects. Many of us developers and database specialists began working with free relational databases like PostgreSQL or MySQL for personal projects or small organizations. Some of us have since moved on to organizations using MS SQL Server and have had to learn to use the new tool. You may be wondering how challenging that is and whether you would struggle with SQL Server under similar circumstances.

What Is SQL Used For?

So you’ve heard about databases and SQL, but you’re not sure what the big deal is. Read on to find out why data skills like SQL are so important. It seems like every other job requires you to know something about data, databases, and SQL. But what are these things, and what are they used for? Who even uses SQL? That’s what we’ll discuss in this article. Why Data Is So Important The Internet and the technology revolution have brought unprecedented opportunities.

An Overview of SQL Text Functions in MySQL

Do you work in MySQL as a data analyst? Then you should know how to use its text functions – data analysts don’t work only with numbers. Reporting requires computations, data classification, and label creation, and you can do all of that in MySQL.  In this article, I’ll explain several of the most common and useful MySQL text functions by discussing what they do and showing how they do it.

What Is SQL?

SQL may be something you hear about from your colleagues. Or you may see it in the job description for your dream role or notice it in a list of the most popular programming languages. So, what is SQL? Should you learn it? Let's find out. Do you think about a career in data analysis and data science? Do you need to interact with relational databases at work? Do you want to improve your performance as a marketer, HR specialist, or researcher by making more informed decisions?

An Overview of Microsoft SQL Server Text Functions

Data analysts use text values when creating SQL reports. You can create your own labels with functions, classify rows based on text value, or do computations based on it. This article covers how to do all that. The text values in databases are not just for reading. As with numeric values, we perform operations on them and manipulate the text. SQL Server has a fair number of text functions.

Learn SQL in 4 Steps

Want to work with data? You’ll need SQL. Fortunately, you can learn SQL in just 4 steps! If you are interested in data crunching or working with data in general, you’ve probably heard something about SQL. Now that data storage is cheap and accessible, data from every transaction can be stored and analyzed. Hence, there’s great demand for people who can capture and work with this data. We’ve even seen entire companies profit from being proficient with data; for example, consider the ever-growing value of Google and Facebook (now Meta).

These SQL Queries Will Help You With Data Analysis

Need to streamline your everyday data analysis tasks? This article explains how basic SQL queries can help. If you are planning a corporate career or any field that involves working with data, you must have come across SQL, or Structured Query Language. SQL was first developed in the 1970s and it continues to be the industry standard for database interactions. Many of you may already have decided to learn this language, given how powerful it is.

How to Combine Two Aggregate Functions in SQL

Having trouble using two aggregate functions in one query? This article will show you how to do it the right way – actually, the two right ways. In data analysis and reporting, we often need to count the number of records or sum them up and then calculate the average of this count or sum. Translated to SQL logic, this is the aggregation of aggregated data, or multi-level aggregation. For aggregation purposes, there are the SQL aggregate functions.

How to Install a MySQL Database on a Windows PC

Do you want to install a MySQL database on your Windows computer? And maybe find out how to start using a MySQL database? In this article, we’ll cover the installation process. MySQL is one of the most popular relational database servers. This is one reason to start using a MySQL database. Among the various editions of MySQL delivered by Oracle, the Community edition is available for free. You can download it from the MySQL website.

Over 40 and Want to Upskill? Learn SQL!

You have several years of experience. Your work has even been written up in a few case studies. Yet, you still have a hard time finding the right path to improve your career. If that's true for you, the answer is to learn SQL. In this article, I'll tell you why. Why learn SQL when you’re already an experienced professional? It’s always good to learn something new. You may want to pick up a new hobby, try out a different industry, or get a new skill to help your career.

How to Use the COALESCE() Function in SQL

SQL users are often faced with NULL values in their queries and need to process them properly. The COALESCE() function helps handle NULL values. Read this article to learn how to use COALESCE() in your queries. SQL tables store data in records, and records are composed of fields. There can be situations where we don’t know the value for a specific field. For example, let’s suppose we have a table with data for persons.

The Recent Rise of DBT and the Analytics Engineer

If you’re interested in data engineering or data analytics, you should know about DBT. And you should also learn about the role of an analytics engineer. We cover both in this article. The rise of Cloud data providers has led to new challenges and possibilities. If you are thinking about entering the data analytics space, it is important to be aware of them; it can help you decide what roles to aim for and what skills to learn.

Top 9 SQL GROUP BY Interview Questions

Preparing for an SQL job interview? This guide will walk you through nine basic, intermediate, and advanced GROUP BY questions that you may have to answer. There are common GROUP BY questions that pop up in a lot of SQL job interviews; in this article, we’ll explain how to answer them. If you are a data analyst or another data professional preparing for an interview, this article aims to help you out.

What Are Window Functions in SQL?

In this article, we discuss what window functions are and how they help you do your job as a data analyst or specialist. No, window functions have nothing to do with the operating system. The window here refers to a set of rows over which the function aggregates data. To learn how window functions work, what functions there are, and how to apply them to real-world problems, it’s best to take the Window Functions course.

Why Should Every Data Analyst Know SQL?

In the 1980s and 90s, it was the emergence of ERPs, processing a few thousand transactions a day. Now, sophisticated Cloud-based systems work with billions of transactions each day. How data is captured and handled has come a long way! Anybody who understands how to use this data has an edge. The good thing is that while the technology working in the background has become more complex, we don’t necessarily need to understand the underlying system’s details to use it.

How to Update Only the First 10 Rows in SQL

Real-world databases require continuous updating. Often, you need to update specific records; you may even want to update only the first row, or the first 10, 100, or 1000 rows. Let’s explore how to update rows for a specified quantity from the top in SQL. What Is the SQL UPDATE? In SQL, an UPDATE statement modifies existing records of a table. You may choose to update entire columns or update rows filtered with a WHERE statement.

Top 5 MySQL Query Tools

Are you looking for a software solution that will make working with the MySQL database even easier? In this article, I’ll tell you about five highly recommended query tools that will save you time. MySQL may already be familiar to you as the most popular open-source relational database management system (DBMS). It works in most applications, which is why the last Stack Overflow report rated MySQL as the most used database.

The SQL Syntax Is Simple: True or False?

Updated on: April 19, 2024 Are you contemplating learning SQL but are concerned about how difficult it may be, especially if you have no prior coding experience? If so, you are not alone. In this article, I show you how simple the syntax of SQL is and that it is worth your time to learn it. You just need to know how to approach it properly. Many people carry the notion that learning SQL is much like learning other programming languages.

What Are the Different SQL JOIN Types?

You just can’t understate the importance of the JOIN when learning SQL. Not only is it one of the most fundamental operations in relational databases, but it is also very versatile with many different types. Although SQL JOIN may be intimidating at first, it becomes a very handy instrument in your arsenal once you understand it. Let’s explore all the SQL JOIN types! We can safely say the JOIN operation is one of the most powerful features of SQL.

How to Write Multiple CTEs in SQL

Leverage the full potential of the CTE by combining two or more of them in a single SQL query. Common table expressions, or CTEs, can be a powerful SQL tool. When you write two (or even more) CTEs together, this power multiplies. In this article, I’ll show you three ways of writing multiple CTEs: Using two independent CTEs in one SQL query. Using two CTEs where the second CTE refers to the first.

The SQL Substring Function in 5 Examples

Working with text data in SQL? We explain how to get values from any point in a string. When you think of working with data in SQL, your first thought is probably a database full of numbers and your SQL code doing very fancy calculations. But text is data, too! It’s very common to find text data in databases. Not only do you have to extract it, but often you also have to manipulate it.

Are You Ready to Become a Data Analyst?

Data analysts enjoy strong career prospects. Do you have the skills required for this role? Let’s find out! If you enjoy working with data, searching for interesting patterns and valuable insights, you may wonder “Should I become a data analyst?” In this article, I’ll explain what data analysts do and what skills a successful data analyst needs. What Does a Data Analyst Do? Data-driven organizations rely on specialists who know how to get value out of data.

SQL and Cloud Databases Are the Perfect Match!

Do you want to do analytics in the cloud? Are you considering learning SQL and wondering whether you can use it with cloud-based databases? Do you want to know how cloud databases and SQL work together? We answer your questions in this article. Read on! You may be an analyst who has heard about cloud databases and SQL and want to learn more. Maybe you are already familiar with them and want to know if the two technologies fit together.

New MySQL Courses Are Here!

A lot of you have been waiting for new MySQL courses on LearnSQL.com – and finally, they’re here! Now you can learn everything MySQL in a simple, understandable, and fun way. We've worked a lot with these online SQL courses and created hundreds of interactive exercises to help you learn this popular SQL dialect. If you want to communicate with the world’s most popular open-source database, our MySQL courses will help you achieve that goal!

LearnSQL.com’s Monthly SQL Practice in 2022

Are you looking for ways to practice SQL? Tired of boring exercises based on unreal scenarios? We have something for you! Every month, we publish a new set of SQL practice exercises. You'll find all of them in the monthly SQL Practice. Here at LearnSQL.com, we believe the best way to learn SQL is through practice. All of our SQL courses (and there are over 30 of them!) are hands-on.

An Overview of MySQL Data Types

What data types are available in a MySQL database? In this article, you’ll learn about numeric data types, text data types, and much more! You may have seen our article about data types in SQL. Here, we focus on the MySQL data types. We will discuss the most commonly used ones: numeric, text, and date and time. If you are interested in the topic, be sure to check out our Data Types in SQL course.

How to Query a Parent-Child Tree in SQL

What are parent-child tree structures in SQL? In this article, we answer that question, talk about query hierarchy, and demonstrate the five most common SQL queries you’ll need for these data structures. Yes, you can use SQL on a parent-child tree structure. I’ll show you how in this article. Along the way, I’ll walk you through five query examples, starting with the easiest and ending with the most complex.

Is Learning PostgreSQL in 2022 Worthwhile?

You want to take a SQL course, but selecting the right one can be too challenging. Perhaps you don't know which dialect you should start with? PostgreSQL is one of the best options. Check out if it is worth it to learn PostgreSQL in 2022. When you search the web, there are many job advertisements for database specialists. Perhaps that is why you have chosen the direction toward development. Or maybe you are just fed up with Excel in your day-to-day duties (which is not surprising) and want to make work easier.

How Do You Get Rid of Duplicates in an SQL JOIN?

Do you have unwanted duplicates from your SQL JOIN query? In this article, I’ll discuss the possible reasons for getting duplicates after joining tables in SQL and show how to fix a query depending on the reason behind the duplicates. Data analysts with little experience in SQL JOINs often encounter unwanted duplicates in the result set. It’s challenging for beginners to identify the reason behind these duplicates in JOINs.

The SQL OVER() Clause Explained

Here is a detailed explanation of the OVER() clause in SQL window functions. This is a detailed guide on using the OVER() clause in SQL window functions. I will focus specifically on this clause, which requires that you have at least a general idea of how window functions work. To make the best out of this article, take a look at the SQL Window Functions Cheat Sheet. Feel free to have it by your side as we go.

PostgreSQL Interview Questions and Answers

Job interviews are always stressful. Interviewing and getting asked technical questions about PostgreSQL is even more of a challenge! In this article, we’ll cover some of the PostgreSQL interview questions you can expect when applying for a new job. By the end of the article, you should be able to handle most of the questions you are likely to face. We’ve previously covered common questions you can expect at a SQL job interview, but this article will be focused on Postgres specifically.

What Is a Common Table Expression (CTE) in SQL?

The common table expression (CTE) is a powerful construct in SQL that helps simplify a query. CTEs work as virtual tables (with records and columns), created during the execution of a query, used by the query, and eliminated after query execution. CTEs often act as a bridge to transform the data in source tables to the format expected by the query. A common table expression, or CTE, is a temporary named result set created from a simple SELECT statement that can be used in a subsequent SELECT statement.

The Top 5 SQL Courses and Learning Platforms for 2022

It’s the New Year! Time to start thinking what good you can do yourself in 2022. If you haven’t decided yet, we want to recommend learning something new – specifically, learning SQL. Maybe learning SQL is already on your 2022 to-do list. If so, take it seriously – learning SQL can change your career path and even your life! It makes sense to find the best SQL courses so you can learn effectively.

How to Include Zero in a COUNT() Aggregate

Explaining how to include zero (0) counts in your SQL query result. Here’s the problem: you want to count something that doesn’t exist, and you want to show your result as zero. How do you do that in SQL? Using the COUNT() aggregate function is a reasonable first step. It will count all the data it finds and return the number of occurrences. But what if there are no occurrences of certain data?

Is SQL Case-Sensitive?

Is SQL case-sensitive? The question seems simple, and you may think it’s a yes-no question. However, the answer depends on multiple factors. Let’s take a look at the possible answers. First of all, this question can be understood in multiple ways. Which part of SQL are you asking about? Do you mean keywords (e.g., SELECT, WHERE, etc.), table and column names, or values in the columns? Which database management system (DBMS) do you have in mind?

Top 5 MS SQL Server Courses for Beginners

Every journey, including a career change, begins with the first step. If you're thinking about learning data analysis or strengthening your MS SQL Server skills arsenal, you've come to the right place. Here are the top 5 MS SQL Server online courses. Enjoy! You've probably heard that today’s organizations rely heavily on data analysis. You heard right. They are looking for employees who can navigate the world of databases and draw conclusions from data.

Will SQL Ever Be Replaced?

Is it worth learning SQL? Is it possible that one of the modern programming languages or no-code solutions will replace SQL very soon? No; it is not that easy to replace SQL and relational databases. Let’s see why SQL is future proof – and why learning it will pay off for many years to come. If you are building your career in a data-driven company, you are probably looking into opportunities to enhance your skill set in data management and data analysis.

5 SQL Subquery Examples

SQL subqueries are basic tools if you want to communicate effectively with relational databases. In this article, I provide five subquery examples demonstrating how to use scalar, multirow, and correlated subqueries in the WHERE, FROM/JOIN, and SELECT clauses. A subquery, or nested query, is a query placed within another SQL query. When requesting information from a database, you may find it necessary to include a subquery into the SELECT, FROM , JOIN, or WHERE clause.

SQL for Startups – Do You Need It?

If you’ve been wondering whether to use SQL in your startup, it’s probably high time to do so. SQL can be an amazing tool for small, fast-growing businesses. But don’t worry if you’re unfamiliar with SQL for startups. Maybe you are not sure what SQL is all about. Don’t worry; you don’t have to make any decisions this second! First, answer these questions: Can you think of any data related to your business – prices, clients, details about clients, production details, budget, costs, strategy, or anything else?

What Are Aggregate Functions in SQL, and How Do I Use Them?

Data is your source of knowledge. And thanks to SQL aggregate functions, you can extract the precise knowledge you need from your data efficiently. Read along to find out more. The core SQL aggregate functions are the following: COUNT(column_name | *) returns the number of rows in a table. SUM(column_name) returns the sum of the values of a numeric column. AVG(column_name) returns the average value of a numeric column.

How to Write a WHERE Clause in SQL

We explain how to use the SQL WHERE clause with practical examples. If you have just started learning SQL and want to know how to retrieve or work with only a specific portion of the data stored in your tables, then this article is for you! The SQL WHERE clause is something you must master if you wish to use SQL for working with data. It is arguably one of the most basic and must-learn constructs of SQL.

How Can SQL Developers Remember Everything They Learn?

Are you at the beginning of your SQL journey? Congratulations, great choice! But you may find the knowledge you gain leaks with time. Find out what SQL developers do to remember everything they learn for a long time. If you learn SQL, the road to the expert level is long, winding, and bumpy. But don't worry – we've all been through it. You know perfectly well it's worth it. And if you don't already know, here are the reasons why you should start learning SQL NOW!

What Is a Rolling Average and How Do You Compute It in SQL?

In this article, we will show three different examples of using SQL to calculate rolling averages. Learn this and you will take an important step in your SQL growth! A rolling average is a metric that allows us to find trends that would otherwise be hard to detect. It is usually based on time series data. In SQL, we calculate rolling averages using window functions. First, let’s talk about what rolling averages are and why they’re useful.

New Window Functions Practice Set Is Here!

Have you learned the SQL window functions? Or maybe, you forgot when and how to use them correctly? Are you preparing for an advanced SQL job interview? You've come to the right place! This is the new Window Functions Practice Set. This is very good news for all SQL learners and database professionals who want to improve their skills. The LearnSQL.com Team is proud to present the new Window Functions Practice Set!

The SQL Count Function Explained With 7 Examples

One of the most useful aggregate functions in SQL is the COUNT() function. If you are new to SQL and want to learn about the various ways to use the COUNT() function with some practical examples, this article is for you. The COUNT() function is one of the most useful aggregate functions in SQL. Counting the total number of orders by a customer in the last few days, the number of unique visitors who bought a museum ticket, or the number of employees in a department, can all be done using the COUNT() function.

2021’s Most Popular Databases

What was the most popular database in 2021? And what do you need to know to use it? If you’re learning SQL, you’re in luck. This year’s most popular database uses SQL. But the list doesn’t end there. Read our article and find out the 5 most popular databases this year. My list was based on the latest research of one of the most important platforms in the IT world: Stack Overflow.

What Is a Recursive CTE in SQL?

The article that’ll show you practical examples of using recursive CTEs in SQL. If you’ve heard about SQL’s recursive CTEs but never used them, this article is for you. It’s also for you if you never get tired of recursive CTE examples. Before we dig into recursion, I’ll remind you what CTEs are and what their syntax is. Then I’ll do the same for recursive CTEs. After that, I’ll show you how recursive CTEs work in three examples.

Still Using Excel for Data Analysis? See Why SQL Is Better!

Are you working with data and still using spreadsheets? Many people think that only programmers or professional data analysts can leverage SQL for data analysis. In this article, I’ll show how people with no IT background can use SQL for their daily work tasks. Not all people working with data have the corresponding job titles like data scientist, data analyst, or data engineer. Following the data democratization trend, almost all office workers do something with data as part of their daily duties – marketers analyze advertising campaigns, HR specialists analyze employee dynamics, auditors analyze credit portfolios, etc.

Read These 5 Data Analysis Books to Jump-Start Your Career

Do you want to pivot into a data analyst role, but you are unsure where to start? Do you do analytics in your job and would like to learn more about the big picture of data? Are you looking for a great data analysis book to read? In this article, you will find our selection of the best books on data analysis! If you are a business professional thinking about picking up data analytics skills, you may be wondering how you should start.

Numeric vs. Decimal Data Types in SQL

In standard SQL, there is a slight difference between the NUMERIC and DECIMAL data types. However, in some variants of SQL, there is no difference! This article will clear up any confusion. In this article, I’ll explain the differences and similarities between SQL’s standard NUMERIC and DECIMAL data types. Then I’ll discuss how these data types work in common SQL dialects. We’ve already posted a more general article on SQL data types; this time, we’ll drill down further on just the DECIMAL and NUMERIC data types.

How to Sort Values in a Specific Order in SQL

Sometimes you will be required to order your data in a particular way, and often the use of typical sort modifiers like ASC and DESC are not enough. This article will show you how to use the CASE statement to order your data exactly how you need it to be. Have you ever needed to order your data in a very specific way? One of the best methods for handling complex sorting is using CASE.

How to Use CASE in ORDER BY in SQL

This article will show you how and when to use CASE in an ORDER BY clause. Have you ever used a CASE statement? I’m sure you have, at least in a SELECT statement. But have you ever used it in an ORDER BY clause? No? You will, once I show you how! Don’t worry if you’ve never used a CASE statement. I’ll show and explain it to you with a short example.

How SQL Helps Everyone in Your Office

I don't know about you, but I really like to make my life easier. If something can be done faster and more efficiently, especially if it's everyday, routine tasks, I’m all for it! This is where SQL works brilliantly. It's not just about complicated data analysis. Everyone in the office works with different types of data, and SQL can help anyone. How? Anything is possible once you learn SQL!

Best Places to Practice SQL JOINs Online

You’ve just started your journey with SQL and you’re not sure what a JOIN is or where to use it. Don’t worry! In this article, you will find out what JOINs are and where you can practice them online. If you have just started learning SQL, you have a lot of topics to cover before you can call yourself a data professional. If you are serious about using SQL, you’ll have to understand JOIN – what it does, when you can use it, and what its different variants do.

Free Course of The Month – SQL Practice Set in MS SQL Server

You have to train a lot to learn a new skill. It is the same with MS SQL Server. Do you want to write good SQL queries? Or maybe you are preparing for a job interview? You've come to the right place! Throughout October you will have access to our amazing hands-on MS SQL Server course for FREE! You probably just thought: “There must be a catch. Why would someone give away SQL courses for free?

Difference Between ROWS and RANGE in Window Functions

Are you familiar with ROWS and RANGE window functions but not sure how they are different? This article makes those differences clear. In using SQL window functions, you’ve probably come across ROWS and RANGE clauses. If you haven’t, they are both parts of the Window Functions course. If you have, it’s quite likely you have been left confused why there are two keywords for the same function. Well, they are not the same!

7 Things Every Data Engineer Should Know

People generate massive amounts of data every day. To get insights from data, organizations need to capture and process them efficiently. That is when data engineers are called up. In this article, I’ll discuss the data engineering role and the skill set necessary to succeed in the role. As the world generates more and more data every year, the IT industry creates new roles to deal with it. These roles include data analysts, data scientists, machine learning engineers, and data engineers.

Find Top Salaries by Department with SQL

This article shows how to get the total salary by department for an organization, using the GROUP BY functionality of SQL. We explain the SQL GROUP BY clause in detail along with conditional filtering using a HAVING clause. Understanding the salary outlay for an organization is one of the common starting points for business leaders. It helps them see who in the organization has the highest total salary cost, department-wise.

The 7 Best Articles about the SQL Recursive Query

Do you want to learn about recursive queries but don’t know where to start? Here’s our selection of seven articles that should help you with diving into the recursive queries world. I won’t lie to you. Learning and understanding recursive queries can be difficult. But difficult things are usually worth trying. And by learning recursive queries, you’re making sure you know how to work with this very powerful tool.

5 Practical Examples of Using ROWS BETWEEN in SQL

SQL window functions are tremendously useful for calculating complex aggregations like moving averages or running totals. The ROWS clause allows you to specify rows for your calculations, enabling even more sophisticated window frames. Here are five practical examples of leveraging the ROWS BETWEEN clause in SQL. Window functions (also called OVER functions) compute their result based on a sliding window frame (i.e. a set of rows). They are similar to aggregate functions in that you can calculate the average, total, or minimum/maximum value across a group of rows.

How to Export a CSV File From a T-SQL Query

Knowing SQL queries to select data from databases allows you to obtain information easily. However, there are many situations in which we need to export data to another platform or application. The CSV file is a solution to this problem. If you'd like to master complete SQL, try out our interactive SQL from A to Z track. It contains 7 hands-on SQL courses that will take you from a beginner to an advanced SQL user.

How Developers Can Build SQL Skills

Even though you cannot build an application using SQL, employers continue to add SQL skills to their job requirements for software developers. In this article, I’ll elaborate on why developers need to know SQL and how you can learn SQL most efficiently. As a developer, you may work on different kinds of projects. Not all of your projects require doing string manipulation, but that doesn’t mean you don’t need to know how to do this.

Top 10 Tools for Business Analytics

Business Analytics is one of today’s hottest career fields. However, success as a business analyst requires that you learn the right skills and software programs. Let’s see what tools you should know if you want to be a business analyst. With the world generating immense amounts of data – and having systems in place to capture and manipulate that data to fuel business growth – job opportunities for business analysts are only going to grow.

How to Use Aliases with SQL JOINs

SQL aliases are custom names that you can give to the columns and tables you include in your queries. Aliases are very useful, as they can greatly improve the readability and maintainability of your query. We’ll be taking a closer look at using SQL aliases with JOIN and why you might need to do so. The best way to master aliases in SQL is practice. I recommend our interactive SQL Practice Set course.

We Have Changed For You!

It's even better than before! LearnSQL.com doesn't just have a new awesome look. We've also been working very hard on the "behind the scenes" stuff, and have changed many functions on our platform to ensure that you have the best possible learning experience. The first glance at the new LearnSQL.com platform shows immediately that a lot has changed. It was very good before, but now it's awesome! We are very proud of our new look and hope that it will make learning SQL even more fun and effective.

Frequently Asked Questions About SQL

Ten SQL questions that you should be able to answer if you’re applying for an SQL job. SQL is a vast topic and a source of endless questions from its users. However, some questions are asked more frequently – usually about concepts that most SQL users will need to know. It’s not surprising that interviewers tend to ask these same questions to SQL job candidates. Either way, knowing these questions is a first step to learning SQL.

How to Show Your Sql Experience

Do you want to work in the IT industry? This is now one of the best ideas for a good career. What should convince you to do so? Demand for specialists, high earnings, and the fact that it is a future-proof profession. Interestingly, it's not gonna be that hard – especially for you, smartie! You just need some skills and good preparation for an interview to be successful. I'll tell you how to land a great job!

Fall 2021 Track of the Season: SQL from A to Z

The ability to analyze data is one of the most sought-after skills in job applicants. Why? Because all organizations want to take advantage of the power of data. And one of the basic tools for that is SQL! See why we have chosen the SQL A to Z track as our track of the season. This fall, take your analytical skills to the next level! Let's start with the basics.

Why You Should Use SQL in Marketing Analytics

Have you been wondering how you could use SQL in your marketing data analysis work? Would you like to create SQL reports to guide your marketing decisions? In this article, you will learn how to use SQL for marketing through plenty of use cases. Are you a marketing professional wanting to better understand the results of your marketing efforts? Do you want better means to prove your point and demonstrate the value you create?

How Hard Is It to Learn SQL Without IT Experience?

Updated on: September 12, 2023 Learning SQL doesn't have to be difficult! Taking an interactive SQL course is a great way to start your career in the high-paying world of IT. When you started your adventure with computers, you surely didn't realize how far you could go. You were probably only a few years old, and your first experience with a computer was probably gaming. Today, computers provide more than just quick access to entertainment; they’re a great tool for earning money.

Free Course of the Month: SQL Server Revenue Analysis

It is impossible to run a business without a good analysis of revenue trends. But how do you do it effectively? You can rely on good old Excel, but a much better idea is to use SQL and databases. Learn how to create SQL reports and track the growth of your business with MS SQL Server. Here is the course, Revenue Trend Analysis in SQL Server. It’s FREE throughout September!

SQL MIN and MAX Functions Explained in 6 Examples

What are the SQL MIN() and MAX() functions? When should you use them as aggregate functions, and when should you use them with window functions? We explain using practical examples. It’s difficult to imagine SQL without the MIN() and MAX() aggregate functions. They are very useful among many data professionals because they allow us to resolve a lot of business problems. In this article, I will explain what each function does and discuss several use cases.

How Much Do Data Analysts Earn in 2021?

How Much Do Data Analysts Earn in 2021? How much does a data analyst earn? We did some data analysis ourselves. Nothing fancy, but it will give you some extra motivation for learning SQL for your data analyst gig. Data, data everywhere! We live in the world of (big) data. Having data is just the first step. Knowing what to do with it, how to interpret it, and what insights it holds, is true greatness.

3 Real-Life Examples for SQL Common Table Expressions

We answer three SQL business questions using CTEs. There are business problems that are often solved in a very roundabout way. While they might get you the correct result, there’s usually a more elegant way to write a solution. Enter the CTEs! They are extremely helpful when it comes to getting a more direct and elegant solution. I’ll show you three business situations where CTEs can be very helpful. You’ll get an idea of when CTEs can be useful.

Why Is the SQL Practice Set my Favorite Online Course?

My friends know that I cannot sit still. I always have to do something, read something, and learn new stuff. It's stronger than me. But I don't complain, because this approach has only helped me in my life. I have done a ton of different online courses, but the SQL Practice Set has proved to be the best so far. Find out why. Learning SQL was not easy for me.

Best SQL Courses for Business Owners

Do you have a business? Can you use the data you collect every day? You would probably do anything for it to succeed. Learn SQL and achieve your goals. Here are the best online SQL courses for business owners. SQL is a great tool that allows you to work with databases. Are you looking to acquire a skill or two to help your business grow? SQL is the answer!

The SQL AVG() Function Explained With Examples

We explain the SQL AVG() function with practical examples, covering how and where you can and cannot use it. The average is probably one of the most widely used metrics to describe some characteristics of a group. It is so versatile and useful that it can describe something about almost anything. If you like sports, you see things like average runs per game in baseball, average assists per game or per season in basketball, and so on.

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.

How to Use CASE in SQL

Updated on: February 19, 2024 If you need to evaluate multiple conditional statements, the SQL CASE statement will do the job. To effectively harness CASE in SQL, grasping its structure and practical uses is key. I'll guide you through real query examples showcasing the power of this versatile statement. Here’s what you need to know to use CASE like a pro. Why is CASE so important in SQL? If you’re analyzing or manipulating data, you’ll often want to define rules based on certain conditions, e.

An Overview of MS SQL Server Data Types

SQL Server data types define what can be stored in a column, local variable, expression, or parameter. It is essential to pick the right data type. Ultimately. your choice of data types affects the whole database. Read on to learn about all of the data types available in MS SQL Server. In this article, we’ll cover numerical, text, and date and time data type categories in detail. We’ll go through their syntax, storage size, and typical use cases.

How to Find the Nth-Highest Salary by Department with SQL

Learn how to find the nth-highest salary in SQL, and you’ll learn how to get the nth value in any data. In this article, I’ll focus on one problem and give you several solutions to that problem. The problem is stated in the title already: find the nth-highest salary by department using SQL. This may sound too specific. But by learning how to solve this, you’ll be able to find the nth value in any data, not just salaries.

What Is the UPDATE Statement in SQL?

The SQL UPDATE statement is used to update existing data in your database. This article will explain its syntax and show you clear examples of the UPDATE statement in action. Effectively updating existing data in a database is required for anyone using SQL; data is only useful if it is kept up-to-date and relevant. In this article, we’ll examine the syntax of the UPDATE statement in great detail. Then we’ll dive into detailed step-by-step examples that will drive home the rules, potential uses, and limitations associated with the SQL UPDATE statement.

I Needed a Good SQL Course… So I Chose SQL Basics.

Why did I decide to take a SQL course? And how did I come across LearnSQL.com? It’s story time! Did I ever think that my professional career would deal with databases? Absolutely not. It didn’t even cross my mind that it would happen. Let me explain why I started learning SQL … and how I got to where I am today. Meet the SQL Newbie I suppose few people have their lives planned from A to Z.

How to Define a Window Frame in SQL Window Functions

The window function is a super powerful resource of the SQL language. At the core of any window function, there is a set of records, called the window frame, defined using an OVER clause. Knowing what records are in the window frame, how they are ordered, and what their upper and lower bounds are, are critical in understanding how window functions work. In this article, we will analyze and explain with examples how you can define different types of window frames.

Use SQL on a Movie Database to Decide What to Watch

We’ll demonstrate how to use SQL to parse large datasets and gain valuable insights, in this case, to help you choose what movie to watch next using an IMDb dataset. In this article, we’ll be downloading a dataset directory from IMDb. Not sure what to watch tonight? Are you browsing Netflix endlessly? Decide what to watch using the power of SQL! We’ll be loading an existing movie IMDb dataset into SQL.

Free Course of the Month: SQL Reports in SQL Server

This is another in our series of free SQL Courses of the Month. This time, you can learn SQL Reporting in MS SQL Server for free. Do you want to be able to prepare even better SQL reports? Or maybe you have some basic knowledge of SQL Server (one of the major SQL dialects) and would like to go a step further? This is the course for you.

New to Data Engineering? Don't Make These Mistakes

It's best to learn from the mistakes of others. This advice also works for data engineering. In this article, you'll find tips to help you advance your career and avoid common data engineering mistakes. The data revolution has produced tremendous opportunities and created various high-paying jobs related to the collection, maintenance, and manipulation of data. Data engineering is one of the most lucrative and interesting jobs of this family.

How to Use SQL to Calculate Customer Lifetime Value (LTV)

Working with data is an essential skill for marketers in today's data-driven world. As a marketer myself, I decided to create a series of articles about calculating key performance indicator (KPI) metrics for SaaS (Software as a Service) companies. We’ll start by calculating customer lifetime value (LTV) using SQL. Data is one of today’s most valuable resources. If you work in a SaaS company, you are flooded with a huge amount of data every day.

An Overview of SQL Text Functions

In this article, we will discuss the ins and outs of the most common SQL text functions, which make it possible for you to find and work on string values. Before we dive into text functions, let’s quickly recap what an SQL function is. Simply put, a function is a predefined built-in piece of code that you can use in your SQL query. For example, the functions SUM(), AVG(), and COUNT() are applied to numerical variables to calculate the sum, average, and number of records respectively.

How to Improve New Employee Onboarding with SQL Courses

Are you looking for something to improve the onboarding process of new employees at your company? If they will be working with databases and SQL, and if you need resources for them to learn quickly, choose interactive SQL online courses. You’ve just hired some new employees. Great! After a long recruitment process, you have finally managed to find people who can do the job and meet your expectations. You may have even used our advice on why it makes sense to Practice SQL Before Interviewing a Potential Employee.

SQL SUM() Function Explained with 5 Practical Examples

Aggregate functions are an important part of SQL knowledge – and there’s no better place to start learning them than with the SUM() function. In this article, you can expand or refresh your SQL with 5 practical examples of SUM(). SQL allows us to do more than select values or expressions from tables. Most operations on relational databases use aggregate functions like SUM() to do computations on data.

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.

How to Keep Unmatched Rows When You Join two Tables in SQL

Learn how to use JOIN to keep both matched and unmatched rows when you join two tables. Joining two or more tables is a skill you need a lot if you’re working with databases. To review and practice your SQL joining skills, I recommend the interactive SQL JOINs course. It contains over 90 exercises and sections on different joining challenges. If you often join tables in SQL, you’ve probably noticed not all data from one table corresponds to data from another table all the time.

Top 10 SQL Window Functions Interview Questions

Many interesting job positions require SQL skills – and that includes window functions, which are not commonly taught in online courses. In this article, I will cover the top window function questions for every experience level. If you’re going for a job interview for an advanced SQL position or for intermediate to advanced data analyst positions, you’ll probably be asked about your knowledge of SQL window functions. Don’t panic! Although these functions aren’t commonly covered in online courses, we’ve got the answers right here.

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.

SQL Track of the Season: SQL Reporting in MS SQL Server

It's the best time of the year for a change! Learn something new and boost your career! This is our SQL Track of the Season: SQL Reporting in MS SQL Server! In this article, we’ll answer common questions about this track. Summer is here. Does the sun make you want to learn something new? Maybe surfing or Portuguese? Maybe you've wanted to learn crocheting all your life? Follow your dreams!

What Is the SQL GROUPING SETS Clause, and How Do You Use it?

GROUPING SETS are groups, or sets, of columns by which rows can be grouped together. Instead of writing multiple queries and combining the results with a UNION, you can simply use GROUPING SETS. GROUPING SETS in SQL can be considered an extension of the GROUP BY clause. It allows you to define multiple grouping sets in the same query. Let’s look at its syntax and how it can be equivalent to a GROUP BY with multiple UNION ALL clauses.

Best SQL Certifications for Leveling up Your Career

If you want to build and strengthen your position in the IT industry, you should look into these SQL certifications. We always encourage you to learn, to gather new skills and experience. Training is really important; without it, you will not make much progress if you want to advance in IT or specifically in the SQL industry. That said, you also need something that can validate your competencies, like SQL certifications.

What Is the INSERT Statement in SQL?

The INSERT statement in SQL is used to add new data to your database. This article will explain how to use it and show you practical examples along the way. When you learn SQL, you focus on getting data out of a database, working mostly with SELECT. In SQL, there are also statements that let you modify data in a database. The first one is the INSERT statement: it adds data to a table.

Primary Key vs. Unique Key: Explaining the Differences

When designing a database, we often need to decide between defining a primary key vs. a unique key. Both of them are crucial during the design and further phases of a database. They allow us to uniquely identify each row, ensure the uniqueness of values in the column(s), and more. Let’s take a deep dive to learn more. This article will go through the primary and unique keys, their functions, and features.

RANGE Clause in Window Functions: 5 Practical Examples

What is a RANGE clause in SQL window functions? Five practical examples will show you how and when to use it. The RANGE clause is used quite rarely in SQL window functions. I don't know why; maybe people are not used to it. This is a shame, because it's far from a pointless clause; it can be very useful, and I'll show you that in five examples. To learn how window functions work, what functions there are, and how to apply them to real-world problems, it’s best to take the Window Functions course.

How to Learn SQL Faster

Struggling with learning SQL? Does it seem like you’re doing everything right, but not making progress as fast as you’d like? Don't worry, I'll help you. Here are some tips for learning SQL quickly and painlessly. Are you wondering how to learn SQL faster? If so, I’m here to help with some practical tips. And once you’ve found the right motivation and the right sources of knowledge, you’ll be able to learn faster.

Free Course of the Month: SQL Server Recursive Queries

Do you want to become a SQL expert? To do this, you need to learn SQL CTEs or Common Table Expressions. They can make your queries clearer and more readable. And during July 2021, you can learn CTEs for free using our interactive Recursive Queries in MS SQL Server course! How can you get this free SQL course? Create a free LearnSQL.com account or log in if you already have one.

Top 15 SQL Interview Questions in 2021

If you are on the lookout for a job in the field of data, you’re almost guaranteed to face SQL interview questions. You might even be asked to complete some kind of SQL coding test. According to KDnuggets, irrespective of the specific role in data – data analyst, data engineer, data scientist, or business intelligence analyst – SQL lands in the top three skills found in postings across Indeed, SimplyHired, and Monster.

Skills Every Data Analyst Should Have

If you’re a student looking for career advice or a specialist seeking new job opportunities, find out if a data analyst job is something worth considering. In today's article, I explain the essential skills required for data analysts and benefits that come from performing such a job. What Is a Data Analyst? Let’s start by defining exactly what a data analyst is. A data analyst is someone who uses their skills to collect, analyze, and report insights from company data.

Data Analyst vs. Data Engineer: A Full Comparison

Do you want to become a data analyst? Or maybe you dream about being a data engineer? Can't make up your mind? I'll help you. Read about the two roles’ history, their market situation, and the skills you need to become one. You already know that it's a good idea to enter the data world and work with databases. But how to do it? Behind which door is the better career waiting for you?

New Basic SQL Practice Course on LearnSQL.com

Hey, did you hear that there’s a brand-new Basic SQL Practice course on LearnSQL.com? This is a great opportunity to refresh your SQL, write some queries, and take your analytical skills to the next level. We’re proud to introduce Basic SQL Practice: A Store! Where did the idea for this new SQL practice course come from? From our users! They’ve let us know that they need more hands-on SQL exercises at a beginner level.

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.

Why Does Your Company Need Data Analysis?

Data is the new gold. That is what the biggest in the business say, knowing the value of the data, the analyses, and the conclusions they bring. If you are wondering why your company needs data analysis and what value it could bring to your business, then this article is for you. Historically, many companies have gone into analytics mainly through financial and accounting data to improve revenue, reduce costs, and eventually increase profitability.

An Overview of PostgreSQL Data Types

It’s vital to know what you actually store in your database. That’s why every column has its data type. There are numerous PostgreSQL data types across various categories. Read on to see which data type suits which use case! In this article, we’ll go through the most common data types used in PostgreSQL. PostgreSQL, also called Postgres, is a well-known open-source object-relational database management system (DBMS). It is SQL-compliant, extensible, and includes all standard relational database features, such as database constraints, transactions, views, triggers, stored procedures, and more.

SQL Terms Beginners Should Know - Part 4

Here it is – another batch of must-know SQL terms. In the first two parts, we covered tables, relational databases, queries, aliases, SQL JOINs, primary keys, and subqueries. Last time, we moved to more advanced terms like INSERT INTO, GROUP BY, and HAVING. Are you ready to dive deeper into SQL terminology? This is the fourth installment of our series on basic SQL terms for beginners (and everyone else). Don’t worry if you missed the previous articles; you can find Part 1 (essential SQL terms), Part 2, and Part 3 in our blog.

Business SQL: How to Calculate Revenue Growth in SQL

Can you use SQL in business? Of course you can! For example, you can calculate revenue growth in SQL – here’s how. As someone who works with data, you already know that SQL is the most used tool in data analysis. But how is SQL helpful in business use? Well, the answer is obvious: analyze business data using SQL! However, there are some specifics with business data that can be tricky if you’re not used to it.

I Took the SQL Basics Course... Here's What Happened!

In this article, I will share my personal story with you. But don't worry – it's not about a scandal or a sad story of failure. I'll tell you how a successful news journalist fell in love with SQL. It all started when I took the SQL Basics course at LearnSQL.com. There are moments in life that change everything. Mine happened when I decided to give up my long-term career and start a completely new chapter in my professional life.

How to Draw Pictures with Recursive SQL Queries

Did you know that SQL can be used for fun? You can even ‘draw’ in SQL using recursive queries! Find out how in this article.  As an SQL user, you already know this language is great for data analysis and data manipulation in general. This is something people get very serious about. But you can also have fun with it by drawing ASCII-art pictures using the SQL code. To do that, you have to know how recursive SQL queries work.

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.

Free Online Courses You Should Take If You Use SQL

If you are an SQL enthusiast, already work with SQL, or want to learn it – you'll surely be interested in acquiring new skills that will support your growth. These free courses will increase your productivity, help you find your way around the work environment, and help you become a better analyst. By the way, they are also fun. Whoever said learning new things is easy has never tried to learn quantum physics (thank you, Mr.

How the Division Operator Works in SQL

The division operator in SQL is used to divide one expression or number by another. This article will show you exactly how to use it and common mistakes to avoid along the way. The best way to practice SQL is our interactive SQL Practice track. It contains over 600 hands-on exercises that conver varios SQL topics, from simple one-table queries, through JOINs, to complex topics like subqueries. It lets you train your SQL skills on real business examples.

A Brief History of MS SQL Server

Microsoft SQL Server is one of the best database management systems in the world. It’s constantly improved and widely used. But do you know how it was created? In this article, I’ll show you the history of MS SQL Server, a solution that changed the world of databases. We’ll explore the stages of MS SQL Server development, find out how the current version differs from the original, and talk about where you can learn or practice SQL Server.

Free Course of the Month: SQL Server GROUP BY Extensions

Do you create SQL reports? Do you want them to be even better and more effective? Are you working with MS SQL Server and want to expand your query writing skills? Here is a great, interactive GROUP BY Extensions in MS SQL Server course. For the month of June, you can learn and finish this course for absolutely free. How can you get this free SQL course in June?

UNION vs. UNION ALL in SQL: What’s the Difference?

UNION and UNION ALL are both used to retrieve records from multiple tables. This article will detail the differences between the two, allowing you to make the best choice for each unique scenario. You can use SQL’s UNION and UNION ALL commands to get data from multiple tables in your database. It’s a common use case, considering that most databases have many tables. Both UNION and UNION ALL are known as set operators.

Where Can I Find a Data Analyst Internship?

Are you wondering how to land a data analyst job without any professional experience? This article is the answer! Finding an SQL-related internship – an important part of eventually landing a data analyst job. Internships enrich your CV and, more importantly, help you learn SQL from the practical side. I will tell you where to find data analyst internships and what you should know about them. That's right! To gain experience, you need experience – especially when you’re entering the labor market or embarking on a new career.

How to Compute Year-Over-Year Differences in SQL

How did your business do this year compared to last year? The year before? Find out how to use SQL to calculate year to year and month to month differences. Year-over-year (YOY) comparisons are a popular and effective way to evaluate the performance of several kinds of organizations. Year to year differences are easy to understand – e.g. it’s easy to understand that your revenue growth is 35% year to year.

How to Keep Focused While Learning SQL

Learning SQL can be a challenge, but it’s one you can handle! I’ve prepared 5 tips to help you stay focused during your learning journey. By choosing the right methods and tricks, you can achieve your goals! If you’re interested in learning SQL, I bet that you are a very ambitious person who wants to constantly develop. You may even be taking your first steps in your career. I don't think I need to explain to you the obvious advantages of learning how to operate database systems; Data is everywhere, applies to everyone, and is increasing by the day.

8 Best SQL Window Function Articles

Do you need a starting point for learning SQL window functions? Not sure which articles provide a solid foundation? We dove into the internet rabbit hole and found the eight best articles dealing with window and analytic functions. There are plenty of articles dealing with SQL window functions. Type those words into Google and you’ll find a huge number of articles returned. Reading articles is a good start if you want to learn something about window or analytic functions in SQL – provided, of course, that the articles you choose are trustworthy and up to date.

What’s the Difference Between UNIQUE and DISTINCT in SQL?

We use the words unique and distinct interchangeably in our day-to-day life. However, these words play very different roles in SQL. Let’s find out what is so different about them and how we can use them in SQL. Despite the words unique and distinct being synonyms, they cover very different things in SQL. The UNIQUE keyword in SQL plays the role of a database constraint; it ensures there are no duplicate values stored in a particular column or a set of columns.

How to Use Aliases in SQL Queries

An SQL alias is useful for simplifying your queries and making the query and its result more readable. This article explains why and how you can use aliases in your SQL queries. You can temporarily rename a table or a column by giving it another name. This is known as an SQL alias. It’s a temporary change that does not affect the actual table name in the database. A temporary table name can also be called a correlation name.

How to Use Comparison Operators with NULLs in SQL

The SQL NULL value serves a special purpose. It also comes with counterintuitive behaviors that can trip up SQL beginners or even experienced programmers. Learn how to avoid these problems when you use NULL with comparison operators. This article is going to help you master best practices for crafting SQL queries that work with NULL values and use comparison operators ( =, <>, <, > ) – which, if you have written any SQL queries before, you know is just about every query you will ever write!

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.

The Best Books for Data Engineers

Are you tired of staring at a computer all day? Maybe it’s time to read a book. Take a moment to check out our list of recommended books for data engineers. They will help you deepen your knowledge about databases. Last year, we shared a list of the best books to learn SQL. This time, I want to introduce five books for data engineers. They are worth reading and will help you learn more about databases.

Best Online SQL Courses for 2021

In this pandemic era, it's no surprise that online learning has become even more popular. To help you narrow things down, I’ve prepared a list of 2021’s 10 best online SQL courses. Find out where you can learn SQL effectively! The number of online courses on offer – especially in the tech industry – is now impressive. You can find something that suits your interests, competences, and professional ambitions. But how do you know which to choose among the many online SQL courses out there?

What Is the WITH Clause in SQL?

In this article, you will learn about the SQL WITH clause, also known as common table expression (CTE). We will go over some examples to demonstrate some of their use cases in light of their benefits. Introduction to the SQL WITH Clause The WITH clause in SQL was introduced in standard SQL to simplify complex long queries, especially those with JOINs and subqueries. Often interchangeably called CTE or subquery refactoring, a WITH clause defines a temporary data set whose output is available to be referenced in subsequent queries.

Want to Work With Data? Learn SQL!

Are you looking for a database job? How are things working out? If you don't know what to do, I suggest you start by learning SQL. Here’s why. In this article, I’ll explain how you can succeed at finding a database job. If you are tired of your current job and fed up with your boss (who hasn't given you a raise in years), read on. Stay with me too if one more stupid Zoom call will make you scream.

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.

SQL Course of the Month – SQL Practice Set

Are you starting your adventure with SQL and looking for a place to practice your SQL queries? Or maybe you are preparing for a job interview? I have good news for you. Throughout May, you will have access to our amazing SQL practice course for FREE! Why is LearnSQL.com giving you a free SQL course? Every month, our users get the opportunity to take one of our great SQL courses for free.

Why Do You Need a Primary Key in a Database Table?

What is a primary key and why is it so important in SQL? Find out in this article. Primary keys are a central element in SQL databases. They provide a unique value that can identify a specific row in a table, which opens up a lot of other benefits. This article covers what a primary key is, how it works, and how to use it in an SQL database.

Breaking With Filing Cabinets: The History of PostgreSQL

This July, PostgreSQL turns 25. It has had an extensive influence on computing. Thanks to PostgreSQL, the world said “Goodbye!” to filing cabinets as the standard for storing and processing data. So, who created PostgreSQL, and how has it changed over the decades? There are quite a few PostgreSQL enthusiasts among my colleagues at LearnSQL.com. It is simply a great database solution. Why? It is free and open-source. So, you can use it for free, even for commercial uses.

What Is the Benefit of Foreign Keys in SQL?

What is a foreign key and why is it so important in relational databases? Learn all the details about foreign keys in this article. One of relational databases’ key features is the ability to link data stored in different tables. These links, called references, essentially act as connections between tables. They are created using the FOREIGN KEY constraint on table columns. In this article, we’ll learn what the FOREIGN KEY constraint does in SQL.

What Is the Role of DISTINCT in SQL?

The DISTINCT keyword in SQL plays an important role in removing duplicate values from your results. This article provides examples showing exactly how DISTINCT works. By default, SQL queries show all the returned rows, including duplicate rows, in the result set. The DISTINCT keyword in the SELECT clause is used to eliminate duplicate rows and display a unique list of values. In other words, the DISTINCT keyword retrieves unique values from a table.

What Do the SQL INTERSECT and MINUS Clauses Do?

Do you know the difference between SQL’s INTERSECT and MINUS clauses and how to use them? You will find examples and explanations in this article. SQL INTERSECT and MINUS are useful clauses for quickly finding the difference between two tables and finding the rows they share. INTERSECT compares the data between tables and returns only the rows of data that exist in both tables. MINUS compares the data between tables and returns the rows of data that exist only in the first table you specify.

Hierarchical Data and How to Query It in SQL

How do you recognize hierarchical data, and how do you query it? Two common SQL questions are about to be answered. Querying hierarchical data is a rather common situation if you’re working with SQL and relational databases. Not that hierarchical data is something mystical and rare; on the contrary, it’s everywhere. So why is hierarchical data so challenging when it comes to relational databases? Mainly, the difficulties occur in translating hierarchical data to relational database principles.

Analyze Small Datasets with SQL

If you think SQL data analysis is useful only when a business is generating millions of rows of data – that SQL cannot help you if you are generating a limited dataset – think again and read on! There is so much talk about how SQL is useful in analyzing Big Data that sometimes the applications of SQL data analysis for small datasets can go unnoticed. Having worked with early-stage businesses – which have just started generating data through daily transactions – as well as big established clients generating terabytes of data, I can tell you for sure that SQL can be an extremely handy tool for just about any business.

Does Music Improve Work Efficiency?

Updated on: April 15, 2024 Do you sometimes have trouble focusing when working or studying SQL? Do you ever lack motivation? I have the perfect solution for you: music for learning SQL! I am excited to tell you about how the right tunes can significantly enhance your efficiency and concentration. Music can soothe the savage beast, they say. It can also inspire action. In general, music is an important element of human life.

Who Should Learn SQL?

If you learn SQL, will you use it in your current (or dream) job? If you learn it, will it help you with your daily tasks? SQL has so much potential that everyone can benefit from it – including you! Read this article to find out how much you will gain by knowing SQL. I could answer the title question with one word: everyone! But not everyone wants to learn SQL.

What FULL JOIN Is and When to Use It

Learn about FULL JOIN, how to implement it, how it compares with the other types of SQL JOINs, and some of its unique use cases. Before we jump into FULL JOINs, let’s quickly recap what an SQL JOIN is. At its core, a JOIN combines data from two or more tables within a database. Tables are usually linked together using unique identifiers in each table, i.e. primary and foreign keys.

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. Table of Contents Introduction to JOIN INNER JOIN Example #1: Showing books and their authors Example #2: Showing books and their translators LEFT JOIN Example #3: Showing all books alongside their authors and translators, if they exist Example #4: Showing all books with their editors, if any RIGHT JOIN Example #5: Books and editors with RIGHT JOIN FULL JOIN Example #6: Showing all books and all editors Example #7: Showing all books, authors, editors, and translators Time to Practice SQL JOINs!

SQL CTE Explained

In this article, you will learn about SQL Common Table Expressions (CTEs). This powerful SQL tool will help you simplify complex queries. Additionally, I will introduce you to the two main types of CTEs and some of their use cases.  CTE Primer The Common Table Expression (CTE) was introduced to standard SQL to simplify long, complex queries (especially joins and subqueries). It is a temporary data set returned by a query that contains data separate from the main query.

SQL Track of the Season: SQL Fundamentals in PostgreSQL

Are you ready for a new challenge this spring? Check out our SQL Track of the Season: SQL Fundamentals in PostgreSQL! In this article, we’ll answer common questions about this track. It’s getting warmer. The flowers are slowly beginning to bloom. This can mean only one thing – spring is here. The world is coming to life after its wintertime lethargy. This is a great time for new challenges. Do you want to add something to your skillset?

How to Find the Next Non-NULL Value in SQL

You need to find the next non-NULL value in a time series, but you don’t know how. Can you even do that in SQL? Yes, you can! This article will show you what to do. If you work with SQL, you will sooner or later confront NULL values. Having NULLs in a database is almost unavoidable. However, sometimes you want to avoid them in your reports. This is quite often true when you’re analyzing time series data; NULL values mean there’s no data available.

What Is the RANK() Function in SQL, and How Do You Use It?

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.

Free SQL Course of the Month – Creating Basic SQL Reports

Do you want to create good SQL reports from scratch? Are you looking for a course that will help you spread your analytical wings? What if I told you that throughout April 2021, you could access one of the best SQL Reports courses for FREE? Here it is: Creating Basic SQL Reports. What's the catch? There is none. LearnSQL.com provides one of their courses for free from time to time.

What Is CASE in SQL?

SQL CASE is a very useful expression that provides if-else logic to your SQL queries. It’s a slightly more advanced topic, but you’ll need it when preparing reports – it will deliver massive value to your personal and professional projects. The SQL CASE statement is a control flow tool that allows you to add if-else logic to a query. Generally speaking, you can use the CASE statement anywhere that allows a valid expression – e.

How to Install MS SQL Server 2019 on Windows

Do you want to install SQL Server 2019 on your Windows PC? How about the latest version of SQL Server Management Studio? I’ll walk you through the process. Soon you’ll be writing T-SQL queries and operating on SQL Server databases! As I write this article, Microsoft SQL Server 2019 is the latest version of SQL Server. It’s the 15th version of one of the most popular database servers in the world.

Is MS SQL Server Still Worth Learning in 2024?

Updated on: March 10, 2024 MS SQL Server is an in-demand skill in today’s job market. Should you learn  MS SQL Server in 2024? In this article, I’ll answer this question. Thinking about whether you should dive into Microsoft SQL Server in 2024 – especially with so many free database alternatives available? MS SQL Server has been a go-to for handling data for ages, thanks to its solid features and reliability.

What Is a NOT NULL Constraint in SQL?

SQL has several ways of dealing with NULLs. In this article, we’ll focus on the NOT NULL constraint and other NULL-related clauses. Understand this and you’ll take an important step in your SQL growth! Before we get straight into the NOT NULL constraint, let’s quickly define what NULLs and constraints are. NULL values are a central concept in SQL databases. The idea behind a NULL value is simple: a NULL value means that we do not have a known value for that field.

Best SQL IDEs for You

Maybe you just started learning SQL. Maybe you already have some experience. Whatever your situation is, choosing the right IDE for you is another step in your development. Why IDE? IDE stands for integrated development environment. It is a software application that enables us to combine various aspects of writing a computer program. An IDE usually contains a source code editor, build automation tools, and a debugger. You might ask why you need an IDE when you have the command line available on your computer.

New SQL Course: GROUP BY Extensions in PostgreSQL

Do you want to take your knowledge of PostgreSQL to the next level? I have something for you: LearnSQL.com’s new GROUP BY Extensions in PostgreSQL course! It will help you get even more out of your data and create better reports and summaries. Fasten your seat belts and prepare to see what GROUP BY can do when it’s turbocharged. First, I have to confess something. I am not objective – I think PostgreSQL is the best and coolest SQL dialect.

What Is a NULL in SQL?

SQL uses NULLs as a special flag that signals the lack of a value for a field or a variable. NULLs should be used wisely so the database gives a faithful picture of the reality it represents. Some people associate NULLs with zeros; others think that NULL means “none”. In SQL, neither of these are true. Simply put, an SQL NULL means that we don’t have a value for that particular field.

SQL JOIN Topics That Require Practice

Are you interested in learning how to join tables in SQL? Where do you start? Many JOIN topics require practice. In this article, we’ll explore these topics by writing codes to solve real-life situations. Hopefully, you will learn which JOIN topics require attention. To make it easier for you, the topics are divided into beginner, intermediate, and advanced. Joining two or more tables in SQL lifts data analysis to another level.

Where Can I Find Good Courses to Practice MS SQL Server?

Updated on: April 6, 2024 Begin your journey to mastering MS SQL Server with the finest practice exercises out there. Whether you are a beginner or seeking to improve your T-SQL skills, explore the top destinations for the most engaging and interactive MS SQL practice courses online. You've started learning MS SQL Server. Maybe you've done a course, watched some YouTube tutorials, and feel pretty confident in your knowledge. What now?

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.

How to Get Descendants of a Parent in SQL

Want to learn how to handle family trees and find descendants of a parent? By reading this article, you’ll learn how to handle hierarchical data. Finding descendants from a parent is a common problem in SQL. If you imagine a family tree, the basic building block that forms the relationships within it is the parent-child relationship. The parent-child relationship is precisely what defines all hierarchical data. Another example of hierarchical data is the manager-employee relationship.

What Do the Operators LIKE and NOT LIKE Do?

The SQL LIKE and NOT LIKE operators are used to find matches between a string and a given pattern. They are part of standard SQL and work across all database types, making it essential knowledge for all SQL users. Gaining an understanding of these operators will allow you to write better queries and demonstrate to potential employers that you have the skills required to filter through expansive data sets.

How to JOIN Tables in SQL

Do you need to display data stored in different tables? Then it’s time to use SQL JOINs! This can be a challenging topic for beginners, so I’ve prepared this comprehensive step-by-step guide on joining tables in SQL. Often, the information that you want to display is stored in several tables. In such cases, you’ll need to join these tables by specifying which rows should be combined with other rows. That’s exactly what JOIN does.

Free SQL Course of the Month – Window Functions

Are you looking for a good SQL window functions course? What if I told you that throughout March, you could access the best window functions course in the world for absolutely FREE? You read that right: you won't pay a dime! Hurry up! Time is running out! But wait – why is LearnSQL.com giving you a free SQL course? Well, we believe sometimes you just have to be good to others.

MS SQL Server vs. PostgreSQL: Which to Choose?

Choosing the DBMS you will use for a new project is a very important and difficult decision. Two popular choices are MS SQL Server and PostgreSQL. To help you decide which would be best for you, I'll compare their features, list pros and cons, and give you some examples. Your selection of database management system (DBMS) depends on the type of business or project you're implementing. First, you need to know:

How Much SQL Practice Do You Need to Become a Pro?

Are you wondering how long it will take to learn and practice SQL before you can call yourself a pro? In this article, I will try to help you answer this question. Being a pro in SQL can mean many different things. Some people would say that being a professional is about mastery of advanced SQL, i.e. window functions or complex subqueries. For other people, being a professional means getting paid for your skills.

SQL Terms Beginners Should Know - Part 3

This is the third part of my list of essential SQL terms for beginners. In the first, you learned what tables, relational databases, and queries are. In the second part of the tutorial, I told you about aliases, SQL JOINs, primary keys, and subqueries. Now, it's time for more advanced database terms. But don't be afraid! I won’t crush you with scientific definitions. I will explain everything simply so that you can easily understand.

How to Use SQL to Filter Your Client Email Database

Looking for ways to be on friendly terms with your email database? Here's my way of using SQL to evaluate a promotion. A client database plays an essential role in developing your sales and marketing strategies. Having a clear and well-structured database has several benefits. For example, you can increase your company's revenue by managing your current and new clients – they can be monitored and offered special promotions. Moreover, such an effort develops customer satisfaction and increases value for your current customers.

Learn SQL And Start Your Journey Towards Personal Growth

Are you at the very beginning of your career and don't know what employers are looking for? Maybe you already have a lot of experience, but feel like it's time to change or update your skillset. Learning SQL can be a great choice. Read on and find out why. Regardless of your career stage, you cannot neglect your personal development. Whoever does not move forward falls behind. As you start learning new things, new opportunities will open up for you, both in your personal and professional life.

How to Practice PostgreSQL Online

PostgreSQL is hot right now!If you want to join a community of people passionate about data, this open-source database system is something you need to try. Like everything we teach on LearnSQL.com, PostgreSQL requires practice. To profit from Postgres – as this dialect is sometimes called – you need to start with the basics. You can watch some tutorials on YouTube or read articles to get to know what a Database Management System (DBMS) is.

What Is GROUP BY in SQL?

GROUP BY is a great SQL feature that allows you to perform powerful calculations on grouped data. Do you want to learn how to get powerful insights from your data? Would you like to know what GROUP BY does and when you should use it? If your answer is yes, keep reading. In this article, you will learn exactly that. Why You Need GROUP BY In today's digitized world – no matter what business you are in – database tables are usually huge, with millions of records.

Enumerate and Explain All the Basic Elements of an SQL Query

“What are the basic elements of an SQL query?” is a popular SQL job interview question. In this article, we review the basic syntax of an SQL query. An SQL query, which requests information from a relational database, consists of several elements. These allow you to select specific columns from specific tables and to filter and sort this information if necessary. In this article, I’ll briefly review these elements by explaining what each element does and how to use it.

Want to Learn Advanced PostgreSQL? Try This!

Why and how should you learn advanced PostgreSQL? I’ll give you some tips that will help you achieve your goals. Keeping up with technology is hard; anyone who has foolishly tried to do so can confirm this (me, for example!). Most of the time, it just doesn't work. And to be brutally honest, keeping up with all the technologies all the time is pointless. You shouldn’t know everything about everything; it’s better to know as much as you need within the technology you use or want to use.

What Does ORDER BY Do?

When analyzing data, it often helps to have rows ordered in a specific way. In this article, I’ll use multiple examples to show how SQL ORDER BY sorts data according to one or more columns in ascending or descending order. Introduction to ORDER BY By default, the order of rows in the output of an SQL query is arbitrary. If you want to sort the output in a particular order, you’ll need to use the ORDER BY keyword.

How to Import CSVs to PostgreSQL Using PgAdmin

Do you work with data and use CSV files? Here is a practical guide on how to import such files into a PostgreSQL database using pgAdmin, one of the best PostgreSQL editors on the market. Let's get right into importing CSVs into a Postgres database. We’ll start by explaining what a CSV file is, then we’ll introduce you to pgAdmin and show you how to do the import process. Don’t worry – it’s easy!

What Is a Unique Constraint in SQL?

To ensure the uniqueness of data in a database, we use the SQL UNIQUE constraint. In this article, we’ll discuss how, when, and why to implement it. The idea of a unique constraint is not unique to SQL; it’s a familiar concept in real life, although we probably call it something else! For example, think of ID numbers. There can be only one social security number (SSN) per person and each one must be unique.

How Much SQL Do I Need to Know?

Learning a new skill or starting a new profession can be a real challenge, especially when you’re unsure of how much you really need to know before taking the plunge. Imposter syndrome is also a real thing – how could you possibly catch up with all those SQL ‘experts’ who seem like they’ve been doing this since they were in diapers? The good news is you can learn SQL quickly and easily, and you don’t need to know nearly as much as you think you do.

SQL Course of the Month – SQL JOINs

If you want to really learn SQL, you can’t skip SQL JOINs. They are some of the most fundamental and commonly used features of the SQL language. That’s why SQL JOINs is our February SQL Course of the Month. What makes SQL JOINs so important? I asked Agnieszka Kozubek-Krycuń, Vertabelo's Chief Content Officer, about it. Here's what she said. Is it true that SQL JOINs are one of the foundations of SQL?

Data Types in SQL

Read this article and learn the ABC of SQL data types. Data types are used to define the type of data stored in a database. However, there are related concepts that a good SQL developer should know: data type conversion, what operations are possible between different data types, date arithmetic, etc. SQL also provides functions that manipulate values of different data types (i.e. functions for string data, date and time data, etc.

Using AND, OR, and NOT Operators in SQL

AND, OR, and NOT are important logical operators in SQL. They help you combine the conditions used to filter records. They are most commonly used in conjunction with the WHERE or HAVING clauses. Furthermore, this topic is a pretty common SQL job interview question. To help you completely understand these operators, I’ll take you through some examples, fully explaining the syntax and purpose of each. Practicing using examples like these is one of the best methods for learning SQL.

Why Aren’t SQL Window Functions Allowed in GROUP BY?

It’s true – the SQL order of operations means window functions aren’t allowed in GROUP BY. But you can use them anyway with this special trick. SQL window functions are one of the language’s most powerful features. However, the syntax of window functions is not easy to master. It has lots of details that can cause beginners to stumble. One of the most common traps is trying to use window functions in GROUP BY.

7 Common GROUP BY Errors

Are you making these errors with GROUP BY in SQL? Find out what they are, how to avoid them, and how to fix them. SQL’s GROUP BY statement can quickly uncover powerful data insights. At first, using GROUP BY can seem easy – e.g. when creating basic SQL reports that you’ll present to business decision-makers. But while learning this powerful feature, you could become trapped in weird errors or get incorrect results caused by improperly written GROUP BY statements.

Why Learn SQL Window Functions in 2021?

SQL window functions provide some extremely powerful and convenient features for data practitioners. This article explains why you should learn window functions and when you should use them. I’ll also provide some examples to help you visualize the concepts. Window functions are part of advanced modern SQL – knowledge of which will definitely enrich the repertoire of any SQL user. Window functions have a broad range of uses and can be applied to almost all facets of business.

Where Can I Find Good SQL CTE Exercises?

Find the top online resources for SQL Common Table Expression (CTE) exercises! CTEs allow you to structure and organize SQL queries efficiently, which is essential if you want to advance your SQL knowledge. A Common Table Expression, or CTE, is a SQL syntax that creates a temporary data set. This set contains separate data than the main query, which can typically be referenced or reused in a subsequent query. A CTE is considered temporary because the result is not permanently stored anywhere and only exists for the duration of the query.

Stories of the LearnSQL Scholarship Program

2020 is behind us. It was an extremely difficult year: We’ve struggled with the Covid-19 pandemic, a worldwide economic crisis, and constant anxiety. Many people have lost their jobs and their prospects for a better tomorrow. That's why we decided to do something positive: establishing a SQL scholarship program. We decided to find people in difficult situations and try to help them. For many, learning SQL can be their chance to get a job and develop their career.

What Is the SQL WHERE Clause?

The WHERE clause is a fundamental part of SQL. This clause filters results and applies conditions to SQL queries. It is most commonly used alongside the SELECT statement. If you’re a complete newcomer to this topic, you can learn the basics of SQL, including WHERE, in our SQL Basics course This article will clearly explain how to use WHERE in a SQL query. After reading it, you’ll have the confidence and knowledge to integrate WHERE into your daily work.

Monthly SQL Challenges in 2021

Did you know that LearnSQL.com provides a monthly SQL Challenge? Every month, we publish a new set of SQL practice exercises. Find out what to expect from our SQL challenges in 2021. Here at LearnSQL.com, we believe that the best way to learn SQL is through practice. After all, writing SQL is a practical skill. That’s why all our SQL courses (and there are over 30 of them!) are interactive: You learn SQL by writing SQL code.

What’s the Difference Between SQL CTEs and Views?

SQL views vs. CTEs: What do they do? How are they different? Which one should you use and when? Get your answers here! In SQL, both CTEs (common table expressions) and views help organize your queries, leading to cleaner and easier-to-follow code. However, there are some important differences between them. This article will walk you through several examples of CTEs and views and explain when to use each one.

What Is LEFT JOIN in SQL?

Get to know the details of LEFT JOIN, one of the most common SQL JOIN types. SQL is mainly about getting data from databases. Very often, you’ll need data to be combined from multiple tables in your database. That’s when JOINs come into play. LEFT JOIN is one of the JOIN types that you are likely to use very often. In this article, I’ll explain the syntax of LEFT JOIN and how it works using several examples and illustrations.

Best SQL Video Tutorials for 2021

Ready for this year’s picks for the best YouTube SQL video tutorials? Here are our top 5 choices! It's been well over a year since I last wrote about SQL tutorials on YouTube. Those seven channels can help you learn the basics of SQL quite painlessly, but now it's time to add to that list with 2021’s top contenders. Which YouTube SQL tutorials are worth your time and attention? I’ve got my favorites, but first, let’s consider an important question:

What Is Auto-Increment in SQL?

In this article, we’ll learn the basics of the auto-increment feature of SQL: what it is and how to use it efficiently. One of the many features offered by SQL is auto-increment. It allows us to automatically generate values in a numeric column upon row insertion. You could think of it as an automatically supplied default value – the next number in a number sequence – that’s generated when the row is inserted.

Winter 2021 Track of the Season: Creating Database Structure

New year, new challenges, and ... a new SQL Track of the Season! Start 2021 by learning SQL and data engineering. In this article, we answer frequently asked questions about our Creating Database Structure track. Maybe you haven't noticed yet that there’s an order to many LearnSQL.com courses; you can learn SQL by doing them in the right order. We call this option our ‘SQL tracks’. These are logically structured and well-thought-out learning paths that will help you take the next steps towards becoming an SQL expert.

SQL Course of the Month – Standard SQL Functions

Are you dreaming of becoming a data analyst? Or maybe you just want to work effectively with your company’s databases? You can – with SQL functions. We’ve selected Standard SQL Functions to be our January 2021 SQL Course of the Month. What will you find inside? I asked Agnieszka Kozubek-Krycuń, Vertabelo's Chief Content Officer, about it. Here's what she said. What are SQL functions? The term reminds me of SELECT or JOIN.

SQL JOIN Tips for Beginners

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.

Why Learn SQL This New Year?

In answering this question, we’ll take a look at the idea behind New Year’s resolutions, explore what SQL is, and see why learning it should be your goal for 2021. We’ve all heard of New Year’s resolutions, and we all have personal experience of how difficult it can be to see them through to a successful conclusion. We’ll examine the history of New Year’s resolutions, why they often fail, and how to ensure your resolution for learning SQL in 2021 doesn’t meet with the same fate as so many others that never made it past the end of January.

2020’s Best LearnSQL.com Articles

We published a whole lot of interesting SQL articles this year. I had a difficult task – choosing the best LearnSQL.com articles of 2020. And here they are. The crazy year of 2020 is coming to an end. How will we remember it? Probably by the COVID-19 pandemic; we stayed home and fought the virus. It was a difficult time. However, many of us did not give up and kept trying to achieve our professional goals.

What Is a Database Index?

Database indexes are critical to query speed and efficiency. Learn when, why, and how to use them – and when not to – in this post. Indexes are very important database objects; they optimize data access and improve database performance by helping the database execute SQL queries faster. Why not take this opportunity to learn how indexes work and how to create them? What Is a Database Index? Indexes are data structures that can increase a database’s efficiency in accessing tables.

What Is an SQL INNER JOIN?

How do you combine data from different tables in one query? An SQL feature called JOIN is the most common operator used to create complex queries. Learn the basics in this article. SQL allows us to select data from more than one table. In fact, the whole idea of using relational databases is selecting data from related tables. And we can use SQL’s JOIN operator to do this. There are many types of JOINs in SQL.

SQL Window Functions for Managers: Who Gets a Raise?

Window functions are one of the most powerful features in modern SQL. In this article, you will learn why window functions are so great. I will list you the most useful window functions and briefly explain when and how you can use them. Simple SELECT statements, in combination with WHERE, GROUP BY, and HAVING, are sufficient for many analyses at work. I used standard SQL for many years before I realized there is something more.

The Best SQL Lectures on YouTube

YouTube contains a vast amount of information. The trick is to know how to find what’s valuable. If you type “SQL lectures” in the YouTube search engine, you will probably get a list of boring or unhelpful clips. However, there are hidden gems, and I’ve compiled a list of the best SQL talks I’ve found on YouTube so far. First, let's establish one thing. I didn't choose any YouTube SQL tutorials when making this list.

Best Online Courses for SQL Window Functions

In this article, I will summarize the top online tutorials and courses available on SQL window functions for enthusiasts of data analysis, data science, and data engineering. The information is here to help you embrace the topic with ease and feel comfortable using window functions in SQL databases. SQL window functions can help you solve some of the most common analysis challenges in business: What are the N most popular products for each month of the year?

How to Use CASE WHEN With SUM() in SQL

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. The best way to learn about CASE WHEN and how to use it with SUM() is our hands-on course Creating Basic SQL Reports. It contains over 90 interactive exercises that will teach you different techniques how to create complex reports in SQL.

SQL Scholarship Program 2020

2020 is slowly coming to an end. It was extremely difficult for everyone. We’ve therefore decided to end it with something positive. This Holiday, we want to help someone change their life. Learn SQL will fund 50 SQL Scholarships for people who cannot afford to learn SQL and who may find it helpful in a difficult situation. We’ll hand out our flagship track - SQL From A to Z - for FREE!

What is an SQL View?

A view is a well-known feature in SQL. It allows you to create a virtual table based on an SQL query referring to other tables in the database. A view stores an SQL query that is executed whenever you refer to the view. This is a convenient way to get the desired data because it is easier to run a query stored in a view than to type a query from scratch.

Practicing SQL for Your First Day of Work

Your new SQL job is likely to surprise you in many ways. To minimize the risk of getting lost in the jungle of data, I recommend you get some additional SQL practice before your first day. There are special SQL practice sets and projects on the internet to help you prepare. You’ll also get help from your colleagues, as programmers are usually open and supportive. If you’re reading this, you’ve probably heard about the opportunities SQL and data science offer.

The Top 10 SQL JOIN Interview Questions with Answers

Have you ever wondered what SQL JOIN questions you might be asked in an interview? Do you feel prepared to answer them? This article covers the most common SQL JOIN interview questions and how to answer them. If you are applying for a job as a data analyst or software developer, you will likely be asked about your SQL JOIN knowledge. SQL JOIN clauses are a great topic for interviewers to quiz you on.

The History of SQL Standards

Has the SQL standard changed in the 30+ years it's been around? Absolutely! Learn about the journey from SQL-86 to modern SQL, today’s standard data language. SQL was created in the early 1970s by IBM. In 1974, Donald Chamberlin and Raymond Boyce published the article SEQUEL: A Structured English Query Language, which introduced SQL to the world. The article contained the BNF grammar (a detailed technical description of the language syntax) for the language, which IBM later thought was a mistake.

SQL Terms Beginners Should Know – Part 2

This is the second part of my list of essential SQL terms for beginners. In the first, you learned what a table, relational database, and query are. Now, it's time for more advanced database terms. But don't be afraid! I won’t crush you with scientific definitions. I will explain everything simply so that you can easily understand. If you want to review the basic SQL terms, see my previous article, SQL Terms Beginners Should Know.

How Do You Write a SELECT Statement in SQL?

SQL is a language to communicate with relational databases, and the SELECT statement is the first thing you’ll learn when you start using SQL. In this article, you’ll learn how to write SELECT statements, from the basics to more advanced. What Is SQL? SQL stands for “Structured Query Language.” It has a long history that started in the 1970s. Being the standard for communication with relational databases, it has maintained its popularity.

SQL Technologies Are More Common Than You Think

Where is SQL being used today? The answers might surprise you! (Hint: SQL technology is basically everywhere.) Is it worth learning SQL? After all, the language was created in the 1970s. Is it still relevant today? The list of technologies that support SQL is very long – and it’s growing. Read on to find out what kinds of programs use SQL. SQL in Databases Relational Databases = SQL Databases It’s no surprise that SQL is used in relational databases.

SQL Course of the Month – Customer Behavior Analysis in SQL

Do you run a business? Do you want to squeeze even more out of your data? Start by analyzing your customers' behavior using SQL! Throughout December, you can learn how to do it for free on LearnSQL.com! I asked Agnieszka Kozubek-Krycuń, Vertabelo's Chief Content Officer, about our December Course of the Month, Customer Behavior Analysis in SQL. Here's what she told me. Let's start with the basics: Why analyze customer behavior?

What Is a Foreign Key in SQL?

What does a foreign key do in SQL? Why would you need one? Learn the ABCs of foreign keys in five minutes. Foreign keys are a central concept in SQL databases; they allow us to enforce data consistency. Usually they work with primary keys to connect two database tables, like a virtual bridge. All SQL developers need to know what SQL foreign keys are, how they work, what data values are allowed in them, and how they’re created.

Aggregate Functions vs Window Functions: A Comparison

If you aren’t familiar with SQL’s window functions, you may wonder how they differ from aggregate functions. When should you use window functions? In this article, we’ll review window functions and aggregate functions, examine their similarities and differences, and see which one to choose depending on what you need to do. After you’ve tackled basic SQL, you’ll probably want to get into some of its more advanced functions. That’s great; these functions make reporting and analysis easier.

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?

SQL in the Open-Source World

Did you know there are free, open-source databases that use SQL? In this article, I'll show you which open-source database solutions can meet your needs. Ever wonder why many people still use paid programs when the same things can be done with free options? Personally, I am an avid supporter of the open-source movement. For years, I have been trying to apply and promote such solutions and support an active community around them.

How To Learn The SELECT Statement in SQL

When you think about learning SQL, one of the first things you come across is the SELECT statement. Selecting information is arguably the most important SQL feature. In this article, we’ll demonstrate the typical use cases for SQL SELECT with practical examples. Read this article if you’re a beginner database user and would like to know what SELECT can do for you. SQL, or Structured Query Language, is the programming language the IT world uses to communicate with databases.

What Is a SQL Constraint?

What are SQL constraints? When and why should you use them? We give examples of common constraints and demonstrate how to apply them. When you’re creating a relational database, you often want to impose certain restrictions on some columns. For example, a column containing a social security number should store only unique values; a column containing a date of birth should not be null, or left empty. These conditions can be ensured by using SQL constraints.

The History of SQL – How It All Began

Who created SQL and why? Find out in this article! Are you learning SQL? Or are you about to take the first step towards working with databases? Great decision! Either way, it's worth knowing the history of SQL – where it came from, who came up with it, and why. Here’s a brief history of SQL, starting with its foundational concept: the database. Ted Codd and the Relational Data Model The first computer databases appeared in the late 1960s.

Practice SQL Before Interviewing a Potential Employee

Has your company grown to the point that you need to hire an SQL expert? Have you found a candidate for the job? How do you prepare for the interview, especially if you don’t know SQL? Don't worry! Follow our suggestions on how to practice SQL. We have tips and tricks to help you feel confident and find the perfect employee. Who You Want To Hire First of all, you need to know the requirements for the new employee.

SQL JOIN Types Explained

What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN in SQL? When should you use each one? We’ve got your answers right here. You want to combine data from two or more different tables, but you’re not sure how to do it in SQL. No worries. In this article, I will show you how to use the SQL JOIN clause to merge data from two tables.

Top 7 Online Courses for Data Engineers

This article summarizes the top online courses available for data engineers. We have picks suitable for beginners as well as intermediate learners. If you’re interested in database design and management, check these courses out! Most individuals who aspire to enter the realm of data aim for data scientist or data analyst roles. While these roles are indeed very rewarding because of their tangible links to customers and business direction, the role of data engineers is equally vital for businesses that operate in a data-rich environment.

SQL Terms Beginners Should Know

Have you started learning SQL? Do you feel a little lost in the maze of new words and ideas? Here’s a list of 10 absolutely essential SQL terms for beginners. When you start learning SQL, there’s a lot to process. And some of it – even basic SQL terms – gets lost in the shuffle. If this sounds like you, bookmark this article; it will be a handy reference.

Where to Go After Learning SQL Basics

Learning to code is – in general – a lot of fun, for sure. Even after a few years in the IT industry, I still love learning new technologies. And I now know that learning with a good plan is even better than learning without one. This also applies to learning with advanced SQL courses. In this article, I'll show you how learning paths can save you some time and a lot of frustration.

Kickstart SQL Learning with Our SQL Basics Course

Updated on: February 19, 2024 Why learn SQL from our interactive online courses? Two reasons: 1) Power up your career. 2) Avoid being a noob. What does it mean to be a noob? “Noob” comes to us from the world of computer games. It’s a combination of “newbie” and “beginner”. It’s not a very nice word. It means that someone has found you an inexperienced player and (even worse) resistant to learning.

SQL Course of the Month – GROUP BY Extensions in SQL

Do you want to develop your SQL skills? Do you want to get more out of your data and prepare better reports and summaries? The answer is learning to use SQL’s GROUP BY extensions. But how should you go about this? I asked the same question to Agnieszka Kozubek-Krycuń, Vertabelo’s Chief Content Officer. As she explains, the secret is in this November’s free SQL Course of the Month: GROUP BY Extensions in SQL.

What is the Difference Between COUNT(*), COUNT(1), COUNT(column), and COUNT(DISTINCT)?

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.

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.

How to Fix a 'Not a GROUP BY Expression' Error

Whether you are an experienced SQL user or only a beginner, your SQL queries may return errors. The accompanying messages are supposed to help you fix them; however, sometimes the messages are not very helpful. The Oracle message “Not a GROUP BY expression” is one such example. Let’s review what this is about and how to fix it. We are going to assume some basic understanding of how GROUP BY works.

How to Learn SQL Common Table Expressions (CTEs)

Common table expressions are very useful for organizing, traversing, and improving the readability of long SQL queries.  Moreover, recursive CTEs, which can reference themselves, solve problems that cannot be addressed with other queries. But how do you master common table expressions in SQL? In this article, I discuss the most effective strategies for learning CTEs and suggest how to address the common challenges of learning common table expressions on your own.

What is a Primary Key in SQL?

Primary keys are an important concept in SQL databases. They provide a unique ID for every row in a database table. As an SQL developer, you should know what primary keys are, what data values are allowed in them, and how to create them. Read this article to learn the ABCs of primary keys in 10 minutes. How to Identify Rows in a Table Tables are the main objects in an SQL database, and as you probably know, tables store records or rows.

Is Learning SQL for Free Worthwhile?

Everyone likes to get something for free, even when it comes to SQL courses. But is free always good? Find out how and where you can learn SQL for free – in a way that’s worth your time. Beginner-friendly database courses and SQL tutorials often promise to teach SQL fundamentals like SELECT, WHERE, GROUP BY, HAVING, and ORDER BY. These commands are the basis of a powerful set of skills for entry-level jobs in data analysis or databases.

What Is a DBMS?

Updated on: February 19, 2024 We generate vast quantities of data every day, and that data needs to be stored somehow. That’s where DBMSs come in handy. Find out what they are and how they relate to databases. If you go on a diet and simply want to keep track of your weight, you can probably use a piece of paper and a pencil. If you then want to chart your daily caloric intake, you’ll probably switch to something like a computer spreadsheet.

Google Analytics and SQL

Google Analytics is a very popular tool among website and blog owners alike. With a simple and quick setup, it lets you gather data about your web page visitors easily. However, did you know that you can export data from Google Analytics to create your own SQL reports? Read this article to find out how. Google Analytics is an extremely popular and powerful solution that lets you collect and analyze various kinds of information about your website.

How to Boost Your Company With SQL Courses

SQL has the power to supercharge the capabilities and performance of your entire company. But if you don’t dip your toes in the water and give some SQL courses a go, you’ll never realize the vast potential of the language. SQL, or Structured Query Language, is your ticket to expanding the scope and the results of your business or organization, no matter what sector you operate in. Whether you’re the owner or manager of your company or simply an employee interested in improving operations, learning SQL is undoubtedly, unquestionably, for you.

What Is a Self Join in SQL? Explaned With 7 Examples

The self join is a popular special case of the SQL JOIN. While most JOINs link two or more tables with each other to present their data together, a self join links a table to itself. This is usually done by joining a table to itself just once within a SQL query, but it is possible to do so multiple times within the same query. Typically, each table in a database stores a specific type of information.

How to Join the Same Table Twice

JOIN is one of the most common statements in SQL. As you may know, it is used to join and combine data from two or more tables into one common data set. In this article, I’m going to discuss special types of joins? in which you combine the same table twice—including joining a table to itself, also known as the self join. When and why do you need to do this?

5 Best Online SQL Courses for Business Analysts

Why bother to learn via an online SQL course? SQL is pure profit – it allows analysts to interpret data efficiently and companies to adopt better strategies. In this post, we’ll look at our top 5 SQL courses for business analysts. Being into finance, economics, and IT systems has brought you to business analysis. It’s a fascinating combination of skills; you’re combining business and technology, which makes you a valuable asset to your company.

How to Create Your First Table in SQL

Creating a database table with SQL is one of the core skills you’ll need to work with data. And it’s easy to learn, so let’s get started! Imagine you’re analyzing data and want to store your results in a database table. Sure, you've done this a million times in Excel. But you’re not sure how to create a table with SQL. Or maybe you’ve noticed that data engineering is in high demand and you want to start learning its core concepts.

Five Essential Features of a Good SQL Course

There are many different platforms offering SQL courses. If you’re a beginner, it may be difficult to choose the right one for you. Find out what we think are the essential features of a good SQL course. Remember, if you make a poor choice at the beginning, you may get discouraged or get into bad habits that will impact your work down the line. What Is SQL? SQL, or Structured Query Language, is a programming language you use to talk to databases.

A Comprehensive Introduction to Window Functions in MySQL

Do a deep dive into the working principles, syntax, and applications of various MySQL window functions. There are many open source databases you could choose; MySQL is consistently one of the most popular. But until 2018, there was no provision for including window functions in MySQL. Fortunately, all that has changed – starting from MySQL 8.0, SQL window functions were now available to MySQL users. Please note that window functions are available only in MySQL 8.

SQL Course of the Month: INSERT, UPDATE, DELETE Data

So, you've started learning SQL, and you already know what the SELECT command is and when to use it! Congratulations! Now, it's time to take the next step towards becoming an expert. You need to know the SQL UPDATE, INSERT, and DELETE commands to modify data in your tables. These are the basics that will allow you to work with tables. But what's the best way to learn them? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo.

How Will Learning SQL Make You a Better Boss?

Updated on: April 6, 2024 Looking to enhance the performance of your team, elevate your own productivity, or boost the efficiency of your entire department or company? Consider learning SQL! Why? Because its benefits are substantial and the return on investment is significant. What does learning SQL and being a better boss have to do with each other? Being a better manager can make your employees happier while growing your business.

Six Window Function Templates to Save in Your Code Editor

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.

New Course: Customer Behavior Analysis in SQL

Good news! A new SQL course is here! We’re happy to announce the release of our Customer Behavior Analysis in SQL course. Do you want to get to know your clients and better understand their needs and behavior? If so, this great interactive SQL course is for you. Discover the power of full customer lifecycle analytics in SQL and know more than your competitors. The LearnSQL.com team is happy to announce the release of a new SQL course on our platform: Customer Behavior Analysis in SQL.

What Is the MySQL OVER Clause?

If you want to learn window functions in MySQL, you need to understand the OVER clause. In this article, we use real-world examples to explain what the MySQL OVER clause is, how it works, and why it’s so awesome. In 2018, MySQL introduced a new feature: window functions, which are accessed via the OVER clause. Window functions are a super powerful resource available in almost all SQL databases. They perform a specific calculation (e.

SQL Means Business - The Way of an Engineer

Have you been wondering why some companies fail and others achieve success? It's not a matter of luck but of the right people. Łukasz Kubicki at Vertabelo deals with business and product development. I asked him how he started his adventure with programming, how an engineer got into business, and if he liked playing computer games. Here's what he said. If you were to write one sentence about yourself, what would it be?

Did You Know LearnSQL.com Has Free SQL Courses?

Who doesn't like getting something for free? Each month, we give LearnSQL.com users a bit of help in their learning journey – a free, fully interactive SQL course. Since April, we have been giving our users the opportunity to learn SQL for free. Each month, we choose one of our SQL courses and give you full access to it for that month – completely free of charge! Cool, right?

How Much Do Data Engineers Earn in 2020?

Data engineering is a hot job right now. What does a data engineer do? And just how much do they earn? We’ve done the research for you. If you are reading this, you’re either starting to learn SQL or you already know some and feel it’s time to look around for a SQL job. Maybe you’re in the midst of tackling our Creating Database Structure track. And, let’s be honest, maybe you need some extra motivation to keep on you track.

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.

How to Join Two Tables in SQL

Querying data from multiple tables is very common when working with relational databases. It is not difficult if you know how to use the dedicated SQL operators for doing this. In this article, you will learn how to join two tables by using WHERE and by using a special operator JOIN, and you will see how to filter rows in the result set. If you want to practice joining tables in SQL, check out our interactive SQL JOINs course.

GROUP BY in SQL Explained

The SQL GROUP BY statement is easy to use, but it can be hard to master. Learn what you can do with GROUP BY, how it works, and how to use it with aggregate functions. GROUP BY is one of the basic SQL tools. However, it might be difficult for beginners to understand how GROUP BY works and how it is used to compute statistics with different aggregate functions. In this article, I’ll use several examples to show exactly how GROUP BY organizes rows and how aggregate functions can be used to calculate statistics on one or more columns.

Top 5 Beginner Online SQL Courses in 2020

Looking for an exciting new career? Data analysis won’t disappoint you! The simplest way to make this possible is by learning SQL, and online SQL courses are the most effective learning method. Don’t know where to start? Here’s an overview of the best online SQL courses for complete beginners. There are infinite reasons for changing your industry. You may want to land a new job because you’re burnt out. You may be bored and want something more challenging.

Creating SQL Courses: Behind the Scenes at LearnSQL.com

Take a peek behind the scenes and learn our secret for creating great SQL courses! Have you ever wondered how LearnSQL.com courses are created? Are we looking at a lot of hard work or just a bit of magic? Or maybe both? Here’s a hint: we rely on proven methods to create user-friendly online courses. But it’s not easy! Read on to see the 8 steps we take when creating a new SQL course.

Why and How to Find Freelance SQL Jobs

If Covid-19 has you all “I-want-to-stop-working-for-the-man-and-enjoy-a-more-fulfilling-life-as-the-master-of-my-own-destiny”, then I’ve got news for you. Not only is it possible to be an SQL freelancer, it’s also a potentially lucrative and liberating career move. It will allow you to work for a diverse range of clients and march to the beat of your own drum. Of course, SQL freelancing isn’t for everyone. You will need a strong sense of self-motivation, some serious hustling skills, and the ability to sell yourself and your services as THE ABSOLUTE BEST all the time, every time - day in, day out.

Six Examples Using MySQL Window Functions

Window functions are an advanced SQL feature available in most popular databases. MySQL had not supported them for a long time, but that changed in Version 8.0. They are helpful not only for analysts and people who create reports, but also for other professionals who use databases to select data needed. In this article, we explain the syntax of some popular window functions with practical examples. What Is a Window Function?

What a Moving Average Is and How to Compute it in SQL

Want to dive deep into time series data and examine long-term trends? Want to know what a moving average is and how to compute it in SQL? Then this article is for you. I’ll explain a powerful feature in SQL called window functions and show how you can calculate moving averages using them. The best way to learn about SQL window functions is the interactive Window Functions course at LearnSQL.

Fall 2020 Track of the Season: SQL from A to Z

During Fall 2020, our main SQL track, SQL from A to Z, will be in the spotlight. In this article, we answer the most frequently asked questions about this track. At LearnSQL.com, our SQL courses are organized into tracks. A track is a sequence of courses designed to help you achieve a specific learning goal. The courses in the track are in a recommended order that progresses from the easiest to the most challenging.

How to Find Duplicate Values in SQL — The Ultimate Guide

Updated on: November 28th, 2023 Find duplicate values in SQL efficiently and avoid wasting resources. This article demonstrates how to locate and address duplicate records using SQL's GROUP BY and HAVING clauses. Database best practices usually dictate having unique constraints (such as the primary key) on a table to prevent the duplication of rows when data is extracted and consolidated. However, you may find yourself working on a dataset with duplicate rows.

SQL Course of the Month – Analyzing Revenue Trends in SQL

We work hard, we learn SQL, and we develop professionally. But why? For our own satisfaction, but also for money! The knowledge of SQL will increase your income significantly. If you are proficient in SQL, you can better analyze your company's revenue. How? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo. In this article, she answers your questions about our September SQL Course of the Month: Analyzing Revenue Trends in SQL.

How CTEs Work

The SQL language offers a feature named Common Table Expressions, or CTEs. Also known as WITH clauses, CTEs are a fairly new addition to SQL. They help you break longer queries into smaller chunks, making your queries much easier to understand. Read the article to find out how to use CTEs and how they differ from traditional subqueries. Common Table Expressions (CTEs), which are essentially named subqueries, were first mentioned in the SQL standard between 1999 and 2000.

How Does SQL GROUP BY Work?

Grouping results is a powerful SQL feature that allows you to compute key statistics for a group of records. GROUP BY is one of SQL’s most powerful clauses. It allows you to see data in a new way and find key metrics (like the average, maximal, and minimal values in a group of records). Without GROUP BY, all the results we obtain are oriented to records. With GROUP BY, we can create groups of records and calculate metrics on each group.

SQL CTEs Explained with Examples

Learn how you can leverage the power of Common Table Expressions (CTEs) to improve the organization and readability of your SQL queries. The commonly used abbreviation CTE stands for Common Table Expression. To learn about SQL Common Table Expressions through practice, I recommend the interactive Recursive Queries course at LearnSQL.com. It contains over 100 hands-on exercises on simple and complex recursive CTEs. What does a CTE do? Why might you want to use one in your SQL code?

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?

Where Can I Find Free Online Data Sets to Practice SQL?

Updated on 4th Sep 2023. Diving into the world of SQL can be an exciting journey. But to truly master this language, you need to practice SQL regularly. In this article, we'll guide you through some free online data sets that will help you take your SQL practice to the next level. Let's get started! You've successfully installed your chosen RDBMS and grasped the basics of SQL. So, what's the next step?

5 Examples of GROUP BY

When you start learning SQL, you quickly come across the GROUP BY clause. Data grouping—or data aggregation—is an important concept in the world of databases. In this article, we’ll demonstrate how you can use the GROUP BY clause in practice. We’ve gathered five GROUP BY examples, from easier to more complex ones so you can see data grouping in a real-life scenario. As a bonus, you’ll also learn a bit about aggregate functions and the HAVING clause.

How to Create a Table in SQL

Creating tables in databases is a very helpful skill, and not just for software engineers or database administrators. It allows you to design or change the structure of a database and store data that’s related to each other. In this article, you’ll learn what a database table is, who creates them, and how to use the syntax of the CREATE TABLE command. What Is a Database Table? A relational database is built of various structures like tables, views, procedures, and triggers.

The Most Popular Databases in 2020

Which database solution is currently most popular? Which SQL dialect should you study? In this article, I’ll share the results of my research and my personal experience. Here are the databases that are worth learning SQL to use. First, let's answer some simple questions: Is SQL still useful? Is it worth learning? If you complete an online SQL course, will it make your work easier? The answer is YES! Why?

How to Spend Less by Mastering the Monthly Budget in SQL

Do you struggle to keep your budget under control? You must have heard about various budget planning materials available as printouts, Excel spreadsheets, or smartphone apps. In this article, we’ll show you another possibility. You’ll learn how to use databases and SQL to identify the weak points of your home budget and spend less. We all need to pay for everyday necessities such as groceries or medical appointments. With money coming in and out of our pockets, it’s easy to lose track of how much we spend and if we have any savings.

Is There any Demand for SQL Language Nowadays?

SQL is 46 years old. That’s 14 years older than I am, and at least 23 years older than the jar of pickles in my refrigerator. SQL is the still-hip granddaddy of the programming world. You know the one: non-ironic suspenders, twirled mustache, tattoo peeking out over his spotted socks. He may be old, but boy, is he fly. If you’ve heard of the NoSQL movement, you may be wondering: why learn SQL in this day and age?

5 Reasons You Might Fail to Learn SQL

Learning SQL isn’t hard, but that doesn’t mean you’ll sail through, problem-free. Here are five things that might cause unwary SQL learners to fail. For me, learning SQL wasn’t always about the joy of discovery. Learning itself is not all about curiosity and the satisfaction of succeeding. Sometimes there is a sense of failure. We’re often told it is better to focus on positives. I believe this. However, it is also crucial to find out what went wrong when we don’t succeed at something.

Learning SQL When You Work and Have a Family

Do you want to learn SQL but feel you can’t squeeze one more thing into your jam-packed life? Here are my tips on learning SQL when you work and have kids. You work full-time and have a family. Daily responsibilities overwhelm you. I’ve been there. Heck, I live there. I work from home and have a family. While I was writing this article, I was also waiting for a call on Zoom, doing the laundry, and cooking some pasta for my son’s dinner.

Can you Join two Tables Without a Common Column?

Yes, you can! The longer answer is yes, there are a few ways to combine two tables without a common column, including CROSS JOIN (Cartesian product) and UNION. The latter is technically not a join but can be handy for merging tables in SQL. In this article, I’ll guide you through the different solutions with examples. When Do you Need to Join Tables Without a Common Column? Beginners just getting started with SQL are usually introduced to standard equi joins, in which two tables are combined by a common column.

Who Should Learn SQL Window Functions?

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.

SQL Course of the Month – Recursive Queries

Recursive Queries is one of SQL’s more advanced features. You could say they divide SQL users into beginners and experts. But how do you learn recursive queries? And why do you need them, anyway? Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, is here to help. In this article, she answers your questions about our August SQL Course of the Month: Recursive Queries. Recursive queries … that sounds very serious.

The SQL HAVING Clause Explained

What is the SQL HAVING clause? Why do you need it, and where do you use it? We’ll explain HAVING in detail. HAVING is a very common clause in SQL queries. Like WHERE, it helps filter data; however, HAVING works in a different way. If you are familiar with the GROUP BY clause and have only heard about HAVING – or if you’re not familiar with HAVING at all – this article is what you need.

Using Subqueries in INSERT, UPDATE, DELETE Statements

Did you know that subqueries can also be used in UPDATE, INSERT, and DELETE statements? Subqueries in SQL are like building blocks that can be used in a variety of statements, not just SELECT. If you find subqueries useful in SELECT, read this article to find out how useful they can be in other instructions. You will be able to create much more complex and powerful SQL queries in no time!

Our 6 Favorite SQL Books

So you want to learn SQL and query databases? Great! Check out these six SQL books for an in-depth look at the language and you’ll be writing queries in no time! You take SQL courses, participate in internet discussions and forums, watch tutorials on YouTube... What else can you do to develop your skills? Sometimes it’s good to reach for old-fashioned sources of knowledge: SQL books. Which book(s) should you choose?

Who Is a Data Engineer?

A new kind of job has recently emerged in the IT world: Data Engineer. At first sight, it may seem very similar to Data Analyst or Data Scientist positions. However, our article explains all the important differences. We present the skills, tools, and everyday tasks of Data Engineers. We also explain how you can get started with this career path.   Thirty years ago, we typically used terms such as “Computer Scientist” when referring to anyone working with computers.

What's the Difference Between Multiple Tables in FROM and Using JOIN?

What’s your approach to joining tables in SQL? In this article, we discuss two approaches and explain why many SQL developers have a definite preference for JOIN. Do you prefer to list multiple tables in FROM and use WHERE to set the join conditions? Or do you use the JOIN keyword? SQL supports both, but there are significant differences between them. Let’s look at each one in detail and then discuss why JOIN is generally preferred.

How to Analyze a Time Series in SQL

Values ordered by time are called a time series. In this article, I’ll show you the most frequent patterns and teach you how to write queries for time series in SQL with the help of window functions. Maybe you’ve had the opportunity to analyze some variables where each value was associated with a time value. Such data – where values are ordered by time – is called time series data.

LearnSQL.com’s New Learning Path: Data Engineering

Calling all future data engineers! Would you like to learn to use SQL? Then our new Data Engineering Learning Path is just for you! We’re very excited to announce the release of a new learning path at LearnSQL.com: Data Engineering, published in July 2020. This is the second learning path offered in our platform. So far, we offered an analytical path, SQL Querying & Reporting, that focuses on writing queries and business reports in SQL.

Using GROUP BY in SQL

Now that you know SQL’s core commands, power up your queries with the GROUP BY clause and aggregate functions. GROUP BY is a SQL clause that arranges data into groups based on a common value (or values). It is widely used to obtain summary information for large datasets as well as for computing basic aggregate statistics. Once you have grasped SQL’s basic commands like SELECT, WHERE, and JOIN, mastering the GROUP BY clause can help you implement your SQL knowledge in real-world business intelligence scenarios.

The LAG Function and the LEAD Function in SQL

LAG() and LEAD() are positional functions. A positional function is a type of window function. If you are not familiar with when and how to use them, what the syntax of each function is, why you might want to use them, and what the differences are, read on! LAG() and LEAD() are positional functions. These are window functions and are very useful in creating reports, because they can refer to data from rows above or below the current row.

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.

How to Learn SQL Fast

Updated on 11th Oct 2023. Are you in a rush to boost your data analysis capabilities? Dive into our comprehensive guide and learn SQL fast! You work with data every day, but you've had enough of how long it takes to process your giant table in Excel. The time has come for a much better tool: SQL! But how long does it take to learn SQL? In this article, I'll show you how to learn SQL fast and become the Vin Diesel of data – how to become the "

How to Calculate the Difference Between Two Rows in SQL

Calculating the difference between two rows in SQL can be a challenging task. It is possible – and there’s more than one way to do it. In this article, I’ll explain how to use the SQL window functions LEAD() and LAG() to find the difference between two rows in the same table. The best way to learn window functions is our interactive Window Functions course. It contains over 200 hands-on exercise that will teach you all window functions concepts, from simple OVER() clause to complex topics such as combining window functions and GROUP BY clause.

What Is Data Engineering?

Data Engineering is a fairly new term in IT. And it’s getting more and more attention. You may have heard about a few similar fields like data science, Big Data, and machine learning. This article explains the difference between these concepts and shows how they can be combined to analyze vast amounts of data. When computers first appeared, their storage capacity was very limited. Do you remember floppy disks? They were popular in the late 20th century and typically offered around 1.

What Is a CTE?

After mastering statements like SELECT, DELETE, INSERT, and GROUP BY, you might search for ways to improve code maintainability, reproducibility, and readability. At that point, you will probably start learning about modern SQL concepts that were introduced in the early 2000s. One such SQL technique is the CTE? (common table expression) —?a temporary named result set. In this article, you will learn what a CTE is and how to use it to improve the maintenance and the readability of your code.

Top 10 Laptops for Learning SQL in 2020

If you want to learn SQL, you’re going to need a device that’s portable and powerful. I recommend a laptop. Here are the features you’ll need, as well as my picks for laptops to get you learning SQL in 2020! I must admit that browsing Amazon’s computer offers or entering any computer store can give you a headache. So many models, with so many options! They differ in components, workmanship, battery life, and screen size and resolution.

What Is a SQL Dialect, and Which one Should You Learn?

Updated on: September 12, 2023 SQL, standard SQL, SQL Server, MySQL, PostgreSQL, Oracle, … You’d like to learn SQL, but you feel overwhelmed with options and you don’t know where to start. We’ll explain what each of these terms mean and what this has to do with SQL dialects. Diving into the world of SQL dialects can feel like jumping into a deep pool without knowing how to swim. There's a ton of stuff to pick up!

Why Learn SQL for iOS and Android Development?

App and program development with iOS and Android is a huge and rapidly growing field in the software world. While some developers get through their careers knowing only their chosen development language, there are plenty of reasons to add SQL to that skill set. Here at LearnSQL.com, we are often asked: “why Learn SQL for iOS and Android development?” To answer that question, we’ve put together a little explanation about exactly why learning SQL makes sense for those in the app development space.

SQL Course of the Month – PostGIS

It's summer, and it's travel time ... at least it would be under normal conditions. The pandemic is still going on, but that doesn't stop us from dreaming about distant trips and visits to beautiful places. For now, most of us will have to do it on a map. Did you know that databases can store geographical data? With interactive maps, if you find a nice summer house on the internet, you can accurately track it and plan the best route there.

Listen to These 7 SQL Podcasts

Are you learning SQL online but craving more? If you're looking for a way to squeeze some sweet SQL knowledge into your day, try listening to a SQL podcast. Choose one of our picks and get ready to amp up your SQL game! If you're like me, you like to get deep into a topic. You’re practicing it whenever there’s an opportunity. Of course, It’s hard to make time. I cherish the days I’m able to sit down and just get some hands-on learning done.

How ORDER BY and NULL Work Together in SQL

Do NULL values come first or last when you use ORDER BY? Are they considered higher or lower than non-NULL values? In this article, I’ll explain how different relational databases treat NULL values when sorting output and how to change the default behavior of the ORDER BY clause. When LearnSQL users practice the ORDER BY clause in our SQL Basics course, they often ask why NULL values appear first in the output and how they can change this behavior.

How to Publish a LearnSQL.com Course Certificate on LinkedIn

LinkedIn draws both job seekers and recruiters. Showcasing your knowledge, skills, and experience on this professional networking site can lead to great opportunities. We know this well at LearnSQL.com. Have you finished one of our courses? Great! Tell your future employer about what you have learned. Here's a step-by-step how-to guide for publishing a course certificate on LinkedIn. I will show you how easy it is to publish a LearnSQL.

Comparing TRUNCATE TABLE, DELETE, and DROP TABLE in SQL

What’s the difference between truncating, deleting, and dropping a table in SQL? Find out in this article. There are a lot of ways to delete data in SQL, including the DELETE, TRUNCATE TABLE and DROP TABLE commands. Which one should you use in a given situation? In this article, you’ll learn the syntax of each command in different database engines like MySQL, PostgreSQL, SQL Server, and Oracle. And you’ll understand the DROP TABLE vs.

How to Learn the SQL Syntax

Read about what SQL is, and choose the best way for you among a wide variety of possibilities for learning SQL and remembering its syntax. What Is SQL? “SQL” stands for “Structured Query Language,” and as it sounds, it is a language dedicated to querying a relational database. In practice, it is used for creating, designing, and managing a relational database. People use SQL to: Create sets of tables and rows Modify database tables and index structures Insert, update, and delete data Retrieve information from a database for a variety of uses such as analytics Relational databases consist of a set of tables containing rows and columns of data.

A Mathematician in the World of SQL

She has a PhD in Mathematics and over 10 years’ experience teaching mathematics and computer science at the University of Warsaw. She knows SQL better than just about anyone I’ve met. Let’s get to know Agnieszka Kozubek-Krycuń, Vertabelo’s Chief Content Officer at Vertabelo. Let's go back in time. How did your adventure with math start? I’ve always enjoyed abstract concepts and problem solving. I was fascinated by variables when we learned to solve simple equations like x+2=5 in primary school.

Last-Minute Preparation Tips for a Database Class Exam

Getting to learn SQL is fun. You don’t really need to spend much time to understand some basic SQL concepts and use them fluently. If you’re a student facing your first database class exam soon, we’ve got you covered. In this article, we explain what you should focus on while learning SQL and studying for an entry-level database exam. Check your knowledge with our 10 sample questions and discover where you can find more SQL practice.

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.

Top SQL Social Media Groups & Channels to Follow

We get news, advice, and funny videos from Facebook, Twitter, and YouTube. Why not use social media to help you learn SQL? You wake up and the first thing you do is check for Facebook notifications. Do you take a photo of your breakfast and share it with friends on Instagram? Maybe you argue with someone on Twitter about which James Bond was the best? Or maybe you are recording a short TikTok video of you singing Lady Gaga?

What’s an SQL Inline Query?

Have you ever heard the term “inline query”? How are they different from subqueries and derived tables? Have you looked this up in numerous places and still don’t know the answer? Let’s embark on a journey and find out together! The first time I heard the term “inline query”, I was a little bit surprised. It doesn’t sound like one of SQL’s nuances and I thought I knew all the basic concepts.

Monthly SQL Challenges

SQL learners sometimes need challenges. Do you want to test your problem-solving skills or your knowledge of SQL? Then take our monthly SQL Challenges! We prepare them on LearnSQL.com every month. Each Challenge relates to a different interesting topic and will help you keep your SQL game sharp. In this article, you'll discover what our LearnSQL.com Monthly Challenges are and where to find them. We’ll also look at the Challenges collected in our Monthly SQL Challenge Mini Track.

Practical Examples of When to Use Non-Equi JOINs in SQL

If you think that two tables in SQL can be joined only using the common field, you will be excited to learn that there are other ways of joining. Non-equi JOINs use different kinds of comparison operators in the JOIN condition. In this article, I’ll guide you through non-equi JOIN examples to show the common use cases for this type of JOIN. Equi JOIN vs. Non-Equi JOIN How do you usually join two tables in SQL?

How to Convince Your Boss You Need SQL Training

Learning SQL is a great goal. Now, if you could only convince your boss that it’s good for the company as well as for you ... You’re aware of the benefits of adding SQL to your skill set. You believe that the rewards gained from you learning SQL will also benefit your employer – it’s not just another way for you to develop your professional profile. But how do you articulate this to your boss?

Top 5 Programming Languages to Learn Alongside SQL

If you already know or are about to learn SQL, you’re well on your way to being a sought-after database administrator, database engineer, or just a general database whizz kid! SQL is a modern, widely-used language that finds application in almost every industry. There is no shortage of jobs with SQL. But what if you want to branch out and learn another language to complement your SQL knowledge and skills?

How to Learn SQL JOINs

JOINs are one of the most fundamental and commonly used SQL commands for manipulating and querying real-world data sets. They are also one of the more challenging SQL topics to master! In this article, you’ll learn an effective strategy to learn the different types of SQL JOINs. When data is stored in a single table, we can easily retrieve rows and get all the information we need. But when businesses scale, so does their data.

What Are the Different Types of SQL Subqueries?

Subqueries can be used in many business cases. What subquery types does SQL offer? And how can you use them efficiently? In this article, I’ll guide you through different subquery types and the typical situations when they are useful. What Is an SQL Subquery? A subquery, or nested query, is a query placed within another SQL query. There are many different scenarios where you may want to include a query in the WHERE, FROM, or SELECT clauses of your main query.

Subquery vs. JOIN

One of the challenges in writing SQL queries is choosing whether to use a subquery or a JOIN. There are many situations in which a JOIN is the better solution, and there are others where a subquery is better. Let’s consider this topic in detail. Subqueries are used in complex SQL queries. Usually, there is a main outer query and one or more subqueries nested within the outer query.

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.

Is it Difficult to Learn SQL?

It’s the number one question asked by the students of SQL and those new to the IT world. Is it difficult to learn SQL? If you came here because you’ve been pondering that very same question, take some comfort in the fact that in no way are you alone. Even the idea of SQL can be intimidating to those of us without a tech background, but it doesn’t have to be that way.

Subquery vs. CTE: A SQL Primer

Have you ever wondered about the differences between a subquery and a common table expression (CTE) in SQL? The concepts seem very similar, but knowing the difference – and when to use each one – will help you write efficient and readable queries. First, we’ll explain the concepts underlying subqueries and CTEs. Then we’ll look at a few examples and finally analyze the pros and cons of each technique.

How to Number Rows in an SQL Result Set

Have you ever needed to add a sequential number to the records in the result of an SQL query? It’s not as simple as it looks! Find out how to do it correctly in this article. To number rows in a result set, you have to use an SQL window function called ROW_NUMBER(). This function assigns a sequential integer number to each result row. However, it can also be used to number records in different ways, such as by subsets.

SQL Course of the Month – Creating Basic SQL Reports

In May, we chose Creating Basic SQL Reports as our course of the month. Why? Because the basis of every successful business is making the right decisions based on proven data and good SQL reports. I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, about this. She knows SQL better than just about anyone and is probably the best person to talk about SQL Reporting. What does it mean to create SQL reports?

Overview of Ranking Functions in SQL

SQL ranking functions make working with relational databases easier, especially for data analysts, marketers, and financial specialists. These functions are used to assign a ranking number for each record and allow you to efficiently create useful reports. SQL ranking functions are window functions. Window functions compute the result based on a set of rows. The word “window” refers to this set of rows. Let’s look at the syntax of ranking functions:

Beginner’s Guide to the SQL Subquery

Subqueries are a powerful SQL resource, allowing us to combine data from multiple tables in a single query. In this article, we’ll teach you everything you need to begin using subqueries. Perhaps the simplest definition of a SQL subquery is “A query inside a query”. Subqueries are so easy to understand that they often appear in the opening chapters of SQL courses. However, there are many variants of subqueries that need to be explained.

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.

SQL in Google Sheets? Yes, We Can!

Did you know that you can write SQL-like queries in Google spreadsheets? This feature is incredibly powerful, versatile, and can replace most of the functionalities offered by Excel’s pivot tables. Read our article to find out how you can easily use the QUERY function to efficiently work with your Google Sheets data. Relational databases share many features with spreadsheets. When we explain what databases are, we often say that they are a bit like spreadsheets except they give us more control over larger amounts of data.

Why Should I Learn SQL Window Functions?

SQL has been around for more than 25 years. Its basic syntax – like SELECT, WHERE, GROUP BY, HAVING, and ORDER BY – is well known. But is there something besides traditional SQL? Can you go beyond the basics and improve your skills? The answer to this question is yes. There is a modern version of SQL. In this article, we are going to dive into the modern version and learn about SQL window functions.

What Is a Nested Query in SQL?

Have you ever wished that you could build a query with several SELECT statements? Good news! You can do this – and a lot more – with SQL’s nested queries. If you’ve been learning SQL (and maybe writing some queries) for a while, you’ve probably encountered cases where it looks like you need another SELECT statement inside your main statement. You may wonder “Is it possible to use nested SELECTs in SQL?

Advanced SQL Courses for Data Analysts – A Complete Review

Even data analysts who already know SQL need to keep their skills sharp. Where can you find the best advanced SQL courses for data analysts? Check out our review of the top online sources! In this article, I present a list of online SQL courses for data analysts. These courses are offered by various platforms. Why wait? Let’s jump right in! 8 Advanced SQL Courses for Data Analysts Let's take a closer look at these courses to decide which platform will be better for you in learning SQL.

You Want to Learn SQL? You've Come to the Right Place!

It is difficult to list all the benefits of learning SQL. You will work faster and more efficiently with a database, you will no longer be dependent on the IT department, and you will be able to analyze the data yourself and draw appropriate conclusions, among others. Add reporting to this, and you will get a very wide range of cool and useful skills. Maybe you want to change jobs or get a promotion?

How to Practice SQL for a Technical Job Interview

You’ve scored yourself an interview for an SQL-related job. Nice work! But perhaps uncertainty is creeping in as your interview date looms closer. Do you know enough SQL to make the cut? What questions are you likely to be asked? What SQL practice should you be doing before your interview? Almost all SQL job candidates go through exactly the same nerve-wracking process. Here at LearnSQL.com, we have the lowdown on all the SQL practice and preparation you’ll need to ace those interview questions and take your career to the next level.

Is SQL a Programming Language?

Updated on: October 30th, 2023 SQL is a powerful tool for communicating with database management systems. When you write SQL queries, you give instructions to the computer and it performs these instructions—it sounds like programming. However, you cannot build an application with SQL as you can with Python or Java. So, is SQL a programming language? For over 50 years, SQL, or Structured Query Language, has been a cornerstone in the world of data management.

SQL Course of the Month – Window Functions

Spring has come. It is nicer outside. It's a great time to learn something new. Which course should you choose? In April, it's worth it to bet on SQL window functions. What are they, what are they used for, and why are they worth knowing? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, these questions. She has a PhD in mathematics and over 10 years’ experience teaching mathematics and computer science at the University of Warsaw.

What Is a SQL Running Total and How Do You Compute It?

The SQL running total is a very common pattern, used frequently in finance and in trend analysis. In this article, you’ll learn what a running total is and how to write a SQL query to compute it. The best way to learn SQL is through practice. LearnSQL.com offers over 30 interactive SQL courses at various level of difficulty. Each course is interactive: there is a little bit of reading, followed by an exercise to practice what you've just read.

Is SQL Worth Learning?

We’re in the 21st century. These are the “ultimate data times” in which loads of information on all kinds of things is available. We want to explore this info even more, slice and dice it, understand where it comes from and what triggers it. With such large amounts of data coming in, people have discovered that spreadsheets aren’t enough. There’s a need for a greater solution, something like a spreadsheet on steroids.

Top 3 Platforms to Learn SQL Online: A Complete Comparison

Do you want to learn SQL online? Where do you start? There are many choices on the internet, and it can be hard to decide. But don’t worry—I tested and compared three major platforms to help you find the best place to learn SQL online! E-learning is on the rise. It gives us infinite possibilities of growing our professional careers without leaving our homes. And increasing our competencies is especially important now that the labor market has become dynamic and unstable.

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.

How to Join 3 Tables (or More) in SQL

Updated on: April 19, 2024 Using JOIN in SQL doesn’t mean you can only join two tables. You can join 3, 4, or even more! The possibilities are limitless. The best way to practice SQL JOINs is LearnSQL.com's interactive SQL JOINs course. It contains over 90 hands-on exercises that let you refresh your SQL JOINs knowledge. It covers a wide range of topics from simple 2-table JOINs, through joining multiple tables and using OUTER JOINs, to joining a table with itself.

Why Take the “SQL Basics” Course at LearnSQL.com

LearnSQL.com’s interactive “SQL Basics” course teaches the foundations of SQL. Discover why we built this online course, our philosophy behind it, and what it contains! What Is SQL, and Why Should You Learn It? SQL is a language used to talk to databases, computer programs that hold data and can process it efficiently. SQL can select data from a database and perform various computations on the data, be they simple or complex.

Differences Between GROUP BY and PARTITION BY

Window functions are a great addition to SQL, and they can make your life much easier if you know how to use them properly. Today, we will address the differences between a GROUP BY and a PARTITION BY. We’ll start with the very basics and slowly get you to a point where you can keep researching on your own. PARTITION BY vs. GROUP BY The PARTITION BY and the GROUP BY clauses are used frequently in SQL when you need to create a complex report.

What is the Best SQL Training Online?

Updated on: April 16, 2024 Mastering SQL training is crucial, but let's face it—you won’t become an expert in just a couple of weeks. With countless resources available, it can be quite a challenge to even know where to begin your SQL journey. How do you effectively practice and hone these essential skills? Savvy and knowledgeable database professionals have consistently been in high demand over the last five years. If you are aiming to advance your career as a database developer, administrator, warehousing specialist, or analyst, SQL training and mastery is an absolute necessity.

Analyze Time Series COVID-19 Data with Window Functions

The COVID-19 pandemic really changed the way we live. No matter where you are, you're being impacted by this unpredictable virus. We do not know what the future holds, but we do believe in science and in better days to come. One thing that makes me as a data analyst particularly happy is that we have publicly available data. We can analyze that data and learn something from it. If you want to explore COVID-19 with the help of modern SQL constructions, keep reading — this article is intended for you.

SQL Window Functions vs. GROUP BY: What’s the Difference?

A very common misconception among SQL users is that there is not much difference between SQL window functions and aggregate functions or the GROUP BY clause. However, the differences are very significant. Perhaps the only similar point between GROUP BY and window functions is that both allow you to execute a function (such as AVG, MAX, MIN, or COUNT) on a group of records. I’d say that window functions’ special power is that they allow us to obtain results that otherwise would be almost impossible to achieve.

Choose the Best Way to Learn SQL

SQL has become a hot topic in the professional world, and many resources have appeared both online and offline for learning SQL. It’s easy to get lost in the jungle of books, tutorials, and courses. Which resources do you choose? If you want to know how to learn SQL quickly and effectively, take a look at my list. There are many reasons for learning SQL. We asked our users about them and learned that there was no universal motive.

SQL Cookbook with Recipes for Success

The internet holds a lot of information and can provide solutions to various problems. SQL users, both beginners and advanced, often turn to the internet for help with SQL queries. This article will help you find the right SQL queries to solve your problems. Learn what the SQL Cookbook is and why you should use it. You will also find a list of the most important recipes, from which you will prepare a great SQL dish with the taste of success.

Are There Any Good SQL Courses for Marketers?

Looking for places to learn SQL online and level up your marketing efforts? Check out these SQL courses. Introduction With the help of IT experts, meticulous marketers analyze information to create advertising strategies. This commonplace state of affairs forces the marketer to rely on data experts and sometimes wait for their availability. But what if marketers could pull the data themselves? They can – by turning into a technical marketer.

How to Get the First Day of the Week in SQL Server

This is additional content for the LearnSQL.com course Customer Behavior Analysis in SQL Server. This interactive course will teach you how to analyze customer lifecycle in a SQL database in over 70 hands-on exercises. You will learn how to find out compare registration rates between periods of time, compute conversion rates in SQL, compare customer cohorts, analyze customer activity and customer churn over time. This course is essential for anyone doing customer analysis in their job.

How to Group Data by Week in SQL Server

This is additional content for the LearnSQL.com course Customer Behavior Analysis in SQL Server. In this course, we showed you how you can analyze the customer lifecycle (customer acquisition, conversion, activity, retention, and churn) with SQL. We discussed customer registration cohorts, or groups of customers who registered during the same period (e.g. same week, same month). Analyzing customer registration cohorts lets you see registration trends and relate registration cohorts with marketing campaigns.

Types of Database Jobs

Updated on: April 11, 2024 Do you dream of high earnings and interesting work? Are you fed up with your boss and his or her annoying vacation stories in exotic countries? Is it time to change your job? Why not learn SQL? Here are some examples of the types of database jobs that may lead you to a better life. What types of database jobs use SQL? Here are some examples, but first, a small caveat.

The 50 Best Resources for Learning SQL (Updated for 2024)

Updated on: December 6, 2023 Do you want to know where to learn SQL? We’ve got you covered with the ultimate list of 50 SQL learning resources, including the best SQL courses, tutorials, books, and much, much more! Learning SQL can be hard enough without wading through thousands of websites and articles. So, we thought we’d do you a solid and put the top SQL resources here in this handy slice of the internet.

Why Window Functions Are Not Allowed in WHERE Clauses

Window functions are extremely powerful, but there are a lot of nuances and little details you need to learn about using window functions in order to use them correctly and efficiently. A fairly common question SQL users have is why window functions are not allowed in WHERE. TL;DR: You can use window functions in SELECT and ORDER BY. You cannot use window functions in WHERE, GROUP BY, or HAVING.

How to Practice SQL After a Video Course

Updated on: April 19, 2024 When you're just starting to learn coding, the most obvious first step is to watch online video courses. They're one of the most popular ways to learn the basics of a new technology without investing a lot of time and money. But you need to do more than that to master the topic. What should be your next step? When someone asks me about how to start learning to code, I often recommend trying video tutorials first.

How to Rank Rows in SQL: A Complete Guide

Don’t struggle with SQL ranking functions anymore! This article will guide you through the most common ranking use cases. Rankings are used around us every day. Sports tournaments, the best movies and TV series on Netflix, stores with the cheapest products—these are only a few examples of rankings you might’ve seen recently. Using SQL RANK functions might be hard sometimes. The variety of different constructions is enormous. You can easily get lost in everything there is to learn about ranking.

How to Practice SQL JOINs

Updated on: November 7, 2023 There is no better way to learn how to practice SQL joins than through hands-on experience. However, there will probably be obstacles along the way. I’ll cover some of these obstacles and give ideas for how to overcome them. While this article won’t turn you into SQL JOINs expert, it will show you how to become one. So, let’s start! Diving into the world of databases?

Stay at Home and Learn SQL for Free with LearnSQL.com

Working remotely is a dream come true for some. You ditch commuting and have more time for the people you love and the things you enjoy. For others, it's a challenge to maintain their focus when there are new distractions. It's also an opportunity to invest the few gained hours in learning something new. Staying at home can be a time when you might find yourself busier than you've ever been, but not getting many things done, and worse, not learning what you planned to.

Video Tutorial or Interactive SQL Course – Which Is Better?

Are you ready to get started with SQL but unsure which learning method is the most effective? In this post, we’ll talk about the pros and cons of learning SQL from an instructional video vs. an interactive online course. Are you a chronic Internet-using student who’s planning to learn SQL? Maybe you did some research but still don’t know which kind of training is worth your (limited) time. We all have families, hobbies, and other after-work commitments, and finding the right resource for learning SQL will save you some time.

Learning SQL? 12 Ways to Practice SQL Online

If you’re currently learning SQL, you may have found yourself knee-deep in reading material and may be wondering how on earth you can bridge the gap between book knowledge and real-life SQL application. In this article, we bring you 12 of the most effective ways to practice SQL online, taking you from a bookworm to a database butterfly in no time at all! All theory and no practice will make you a frustrated SQL user!

How to Stay Healthy When Learning SQL

So, maybe you’re learning SQL. Congratulations! Or maybe you already work as a data analyst, DBA, or data scientist. That’s great too! Either way, you are most likely spending hours in front of a computer. I will give you tips on how to avoid bad habits and take care of your health while learning and/or working with SQL. Have you ever wondered how sitting in front of a computer affects your health?

How to Become an SQL Developer

There is no simple answer to the question “How do you become an SQL developer?” However, if the answer were too complex, there would be no point in writing this article, and yet I’m doing it. So, somewhere along the way, we’ll find the answer. As said in the intro, there is no magic wand that will turn you into an SQL developer. But reading this article will save you some time and help you focus on what is important to achieve your goal.

How Long Does It Take to Learn SQL?

Is it hard to learn SQL? How long does SQL mastery take? This article will answer those questions and get you started with the most useful SQL commands. How long does it take to learn SQL? If you’ve ever dabbled in Spanish or French, you know that learning a new language is tough and can take years. Luckily, mastering SQL is a much faster journey than conquering por/para or un, deux, trois.

HAVING vs. WHERE in SQL: What You Should Know

This article is about SQL’s WHERE and HAVING clauses. Both clauses are part of the foundations of the SQL SELECT command. They have similar uses, but there are also important differences that every person who uses SQL should know. Let’s see what’s behind the HAVING vs. WHERE debate. In this article, we’ll suppose we work for a government social agency supporting people or families whose income is below a certain threshold.

How to Practice SQL

Updated on: December 5th, 2023 Are you familiar with SQL's core concepts like aggregation functions, JOINs, GROUP BY, and ORDER BY? That's a great start. But to truly master SQL – especially for data analyst roles and job interviews – it's crucial to understand how to practice SQL effectively. This article provides a comprehensive guide to the best methods to practice SQL. You’re here because you're eager to enhance your SQL skills and become an independent database user.

SQL INSERT, SQL UPDATE, SQL DELETE – Oh My!

Need to understand SQL INSERT, UPDATE, or DELETE? We'll get you up to speed with a comprehensive How-To and useful examples! SQL INSERT, UPDATE, and DELETE statements—what are they all about? If you're a data engineer, a database administrator, or even just your average data fanboy or girl, one day you're going to find yourself with a database that becomes your "baby." Charged with this special bundle of joy, you're going to need to feed and change the little fella.

SQL, Databases, and Hollywood Movies

Policemen, doctors, lawyers, scientists, teachers: These are the professions that we often see in Hollywood movies. But are movies also trying to show what the work of data analysts looks like? Here is a list of six movies in which screenwriters, directors, and producers decided to cast SQL and databases in the main roles. Data analysis is most often associated with business, reporting, and making key decisions for the company.

Difference between GROUP BY and ORDER BY in Simple Words

For someone who is learning SQL, one of the most common places to get stuck is when learning the GROUP BY command. GROUP BY and ORDER BY are two important keywords in SQL that we use to organize data. The difference between GROUP BY and ORDER BY is that ORDER BY is more simple than GROUP BY and is usually introduced early in an SQL course. Sometimes, people are quite confused over these two concepts (SQL ORDER BY vs.

Join us on Facebook–We Can Learn More Together

We are so happy that you have joined us to learn and develop your SQL skills! We want to invite you to a new Facebook group, We Learn SQL. It is a great place for anyone interested in meeting like-minded people who also want to learn about database-related concepts. Learning together is easier, don't you think? Joining this group is a great opportunity to begin sharing your learning experiences with others.

Grouping Data in SQL Server

People who work with data know that data grouping can sometimes be a chore. If you struggle and waste hours with Excel, OpenOffice, or some other tool trying to group various sets of data, take a look at this article and learn how to do the work much quicker and easier by using SQL. You often find yourself in a situation where you need to analyze data and present the results in a form other than the one in which the data is stored.

SQL Order of Operations

SQL is not a traditional programming language in which you write a sequence of instructions in a given order of execution. Instead, SQL is a "declarative" language, which means that by writing a SQL query, you declare what data you expect as a result of the query, but you don't indicate how to obtain it. Six Operations to Order: SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY By using examples, we will explain the execution order of the six most common operations or pieces in an SQL query.

The Most Important SQL Queries for Beginners

How do you get data from a table? How do you create or delete a table? How do you display distinct records? How do you select rows which store a specific value in a column? You can easily do all of this by writing basic SQL queries. This guide discusses the 30 most important SQL queries for beginners. Let's take a look. 1. Retrieving Data From All Columns This is a very basic query to display all data from a table.

YouTube Tutorials That Actually Teach You Some SQL

YouTube is not just funny cats, music clips, and viral videos. It can also be a mine of knowledge – if you know where to look. Can YouTube tutorials really help you learn SQL? Let's say you're a marketer or an accountant. You work with databases every day. But when it’s time to write a query and get specific data, you need to call someone from IT. Why not learn to do it yourself?

24 Rules to the SQL Formatting Standard

Writing queries to a database requires knowledge about SQL syntax, but this is not all you should know. Best practices for writing professional SQL code require good formatting skills. In this article I discuss why this is so important and what are the basic rules you should follow. Why is it Worthwhile to Format SQL Code? Beginner SQL programmers often don't pay much attention to formatting their code. If you think formatting is something that can be safely ignored, look at the code below:

SQL INNER JOIN Explained in Simple Words

In this article, I will cover perhaps the most important element of the SQL language. That's right! I'm talking about the SQL INNER JOIN clause. As you know, in a database the data are stored in several tables. In my last article, I covered how to create SQL queries when the data you need is in only one table. But what if the data you need is in two tables?

Forget About Excel, High Five With SQL

Find out why you should forget about Excel and start using SQL even if you're not an IT expert. We'll show you how easy it is to learn SQL, how it can make you work better, and how LearnSQL.com makes the learning process fun. "I Don't Deal With Data" We frequently hear the sentence above from people outside the IT industry. Well, it's not entirely true. Data is now almost everywhere.

14 Differences Between Standard SQL and Transact-SQL

In my last article, I roughly described how standard SQL differs from T-SQL and who should learn which. Now I'd like to focus on the syntax differences and illustrate these differences with examples. If you think T-SQL is an extension implementing all the features from standard SQL, you aren't right. However, in SQL Server you will find almost all the features of the SQL standard. In this article you will find examples of some of the differences in syntax between standard SQL and Transact-SQL.

Get to Know the Power of SQL Recursive Queries

Most commonly, the SQL queries we run on a database are quite simple. Well, that depends on your role, of course. Analysts in data warehouses retrieve completely different sorts of information using (very often) much more complicated queries than software engineers creating CRUD applications. However, sometimes it's simpler or more elegant to run a query that is a little bit more sophisticated without needing further data processing in the code.

What's the Difference Between SQL and T-SQL?

If you are beginning to learn SQL and are confused by the differences between standard SQL and other similar languages like T-SQL, this article will help make things clear. You’ll not only learn about the difference between SQL and T-SQL but also find explanations concerning which topics would be better to start learning first: standard SQL or something more specific like MS SQL Server. What is Standard SQL? SQL (Structured Query Language) is a basic ANSI/ISO standard programming language designed to operate on data stored in relational databases.

Microsoft SQL Server Pros and Cons

Thinking about using Microsoft SQL Server? If so, you’re in the right place. In this article, we’ll go over the pros and cons of Microsoft SQL Server and evaluate the platform from both a company’s and a data specialist’s perspective. What Is Microsoft SQL Server? Before diving into the pros and cons of Microsoft SQL Server, I’ll explain what it is. In technical terms, it is a relational database management system (RDBMS) developed by Microsoft.

How to Install PostgreSQL on Windows 10 in 5 Minutes

It may look like a complicated task to install PostgreSQL, Oracle, or SQL Server or any other database software, but it really isn’t! These days, most relational database management systems come with installation wizards that make the process much simpler. In this article, we’ll look at how to install PostgreSQL and test that the installation is working. Install PostgreSQL: Steps Involved To install PostgreSQL, we’ll complete the following tasks:

How SQL supports data-driven organization

Typical business users make decisions based on gut feelings, but this can't get them so far. In this article, we'll look at how learning to write basic SQL queries helps your company become a data-driven organization. Businesses face many decisions. Do we increase our advertising budget in one region or the other? Are certain products selling quickly enough? What we should do if they aren't? Most of these decisions are driven by intuition, but organizations that make the most business impact use data-driven decision-making.

Microsoft SQL Server 2017 Installation Step by Step

Microsoft SQL Server is one of the most popular professional database servers on the market. In this guide, I’ll show you all SQL Server 2017 installation steps to help you install it on the Windows operating system together with SQL Management Studio. If you want to learn T-SQL, the dialect of SQL used in SQL Server, check out our SQL from A to Z in MS SQL Server track.

How to Begin Running SQL Queries

In this article, I’ll explain how to run a SQL query to help you execute your first one. Let’s jump right in! Running SQL queries for the first time is not a complex task, but it can seem intimidating at first if you’re a complete beginner. But once you get past that initial roadblock, you’ll be able to focus on learning SQL and writing more interesting queries to meet your business needs.

Our Picks for 2020’s 7 Best Online SQL Schools

If you’re looking for the best online SQL courses but aren’t sure where to start, you’re in the right place. I evaluated the top 7 ranked SQL schools available online to help you find the right solution. While summer is a great time to relax and get away from work, it’s also an excellent opportunity to learn new skills – like SQL! Thanks to SQL schools putting their courses on the internet, learning new tech skills is super easy and you can choose from a variety of formats to suit your needs.

5 Great Benefits of Learning SQL

If you want your business to succeed in 2017, it’s absolutely critical that you understand your data; this is why you should get acquainted with SQL ASAP. But there are other reasons to learn it that may not be obvious. In this article, I’ll show you 5 huge benefits of learning SQL! Don’t fall for the common trap—analyzing data isn’t just a concern for those competing at national or corporate levels.

Tag: Learning Sql

The Best SQL Books for 2024

In 2024, finding the right resources to learn SQL is more important than ever. But with so many options out there, how do you choose the best one? In this guide, I will share some top SQL books to help you learn and master SQL this year. SQL, or Structured Query Language, is a tool that helps you work with data stored in databases; it lets you find and change information quickly and easily.

We Have Changed For You!

It's even better than before! LearnSQL.com doesn't just have a new awesome look. We've also been working very hard on the "behind the scenes" stuff, and have changed many functions on our platform to ensure that you have the best possible learning experience. The first glance at the new LearnSQL.com platform shows immediately that a lot has changed. It was very good before, but now it's awesome! We are very proud of our new look and hope that it will make learning SQL even more fun and effective.

Tag: Left Join

9 Practical Examples of SQL LEFT JOIN

LEFT JOIN is one of SQL's most common JOINs. Make sure you know all its ins and outs by going through all nine of our real-life LEFT JOIN examples. LEFT JOIN – alongside INNER JOIN – is one of the essential SQL tools you need to work with data from two or more tables. But how and when should you use it? These nine LEFT JOIN examples will point the way.

What Is a LEFT OUTER JOIN in SQL? 4 Practical Examples

Today’s article will discuss the LEFT OUTER JOIN in SQL. We’ll go through several examples of LEFT OUTER JOIN usage and compare it with INNER JOIN. A JOIN is an SQL feature that allows you to combine data from two or more tables. The nature of relational databases makes JOIN one of the most commonly used features in SQL. Why? In practice, you’ll very seldom have all the required data in one table.

How to LEFT JOIN Multiple Tables in SQL

Can you LEFT JOIN three tables in SQL? Yes, indeed! You can use multiple LEFT JOINs in one query if needed for your analysis. In this article, I will go through some examples to demonstrate how to LEFT JOIN multiple tables in SQL and how to avoid some common pitfalls when doing so. The best way to practice different types of joins is our interactive SQL JOINs course. It contains over 90 hands-on exercises that cover simple 2-table joins, joining multiple tables, LEFT JOIN, FULL JOIN, and many more.

Tag: Like

How to Use LIKE in SQL: SQL Pattern Matching

SQL pattern matching is a very important and useful ability. In this article, we look at how you can perform it using LIKE in SQL. SQL Pattern matching is a very simple concept. It allows you to search strings and substrings and find certain characters or groups of characters. Apart from SQL, this operation can be performed in many other programming languages. In this article, we’ll examine how you can use LIKE in SQL to search substrings.

Tag: Linux

Top 5 Linux Distributions for SQL

The world is divided into Linux lovers and people who have never tried it before. Still working on Windows or macOS? Do you want to learn SQL? Do you know a large proportion of IT professionals use Linux? It's not a coincidence. But which Linux distribution should you choose for learning SQL? Here's my factsheet to help answer that question.   Linux Distribution: What Is It? What is a Linux distribution?

Tag: Lonline Practice

How to Join Only the First Row in SQL

In your projects, you may encounter situations when you have many orders corresponding to one customer or many temperature observations corresponding to the same location, but you only need to join the first row with the most recent order or the most recently observed temperature to the corresponding record in another table. In this article, I’ll go through several ways to do this in SQL. The best way to practice basic and advanced SQL is our interactive SQL Practice Set course.

Tag: Lsq

The Best YouTube Channels for Learning SQL

Updated on: April 21, 2024 Discovering the best YouTube channel from which to learn SQL is essential for beginners and enthusiasts alike, as SQL learning doesn't have to be challenging. If you're wondering whether watching online videos is the most effective way to master SQL, it's crucial to explore and identify high-quality YouTube channels dedicated to teaching SQL. This approach ensures you gain a comprehensive understanding of SQL through engaging and informative content.

Tag: Lsql

What Is the OUTER JOIN in SQL?

Even if you are new to SQL, you must have come across the term OUTER JOIN. In this article, I will explain what OUTER JOIN in SQL does. I’ll use some practical examples to demonstrate how it is used in day-to-day SQL applications. If you want to use SQL for practical purposes, learning the different JOINs is extremely important. In fact, you will be using a JOIN in just about every second query you write.

Tag: Marketing

Are There Any Good SQL Courses for Marketers?

Looking for places to learn SQL online and level up your marketing efforts? Check out these SQL courses. Introduction With the help of IT experts, meticulous marketers analyze information to create advertising strategies. This commonplace state of affairs forces the marketer to rely on data experts and sometimes wait for their availability. But what if marketers could pull the data themselves? They can – by turning into a technical marketer.

Tag: Masking Nulls

Useful SQL Patterns: Matching Nulls by Masking Nulls

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. In database development, SQL developers often find themselves returning to the same SQL statements. Learning about these now, early in your SQL journey, will help you work more efficiently. Today, in the first post of this series, we will consider the match by null SQL pattern related to SQL data matching.

Understanding the Use of NULL in SQL Three-Valued Logic

NULLs are necessary in relational databases, and learning to use them is fundamental to SQL success. However, NULLs should also be handled with care, as we explain in this post. In relational databases, we don’t always have a value to put in a column. For example, suppose we have a table called “persons” that has “first_name”, “last_name”, “birth_date” and “marriage_date” columns. What value will we store in the “marriage_date” column for single persons?

Tag: Matching Nulls

Useful SQL Patterns: Matching Nulls by Masking Nulls

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. In database development, SQL developers often find themselves returning to the same SQL statements. Learning about these now, early in your SQL journey, will help you work more efficiently. Today, in the first post of this series, we will consider the match by null SQL pattern related to SQL data matching.

Understanding the Use of NULL in SQL Three-Valued Logic

NULLs are necessary in relational databases, and learning to use them is fundamental to SQL success. However, NULLs should also be handled with care, as we explain in this post. In relational databases, we don’t always have a value to put in a column. For example, suppose we have a table called “persons” that has “first_name”, “last_name”, “birth_date” and “marriage_date” columns. What value will we store in the “marriage_date” column for single persons?

Tag: Matching Patterns in Sql

How to Use LIKE in SQL: SQL Pattern Matching

SQL pattern matching is a very important and useful ability. In this article, we look at how you can perform it using LIKE in SQL. SQL Pattern matching is a very simple concept. It allows you to search strings and substrings and find certain characters or groups of characters. Apart from SQL, this operation can be performed in many other programming languages. In this article, we’ll examine how you can use LIKE in SQL to search substrings.

Tag: Max

SQL MAX Function

Learn about the SQL MAX function, which is used to find the highest value in your dataset. This article explains how to use the syntax of MAX function and shows typical usage examples. The SQL MAX function is an aggregate function that returns the maximum value in a column. MAX function, together with its counterpart MIN function, is useful for summarizing data in data analysis. It can help you to compute the range of values in a dataset.

SQL MIN and MAX Functions Explained in 6 Examples

What are the SQL MIN() and MAX() functions? When should you use them as aggregate functions, and when should you use them with window functions? We explain using practical examples. It’s difficult to imagine SQL without the MIN() and MAX() aggregate functions. They are very useful among many data professionals because they allow us to resolve a lot of business problems. In this article, I will explain what each function does and discuss several use cases.

Tag: Min

SQL MIN and MAX Functions Explained in 6 Examples

What are the SQL MIN() and MAX() functions? When should you use them as aggregate functions, and when should you use them with window functions? We explain using practical examples. It’s difficult to imagine SQL without the MIN() and MAX() aggregate functions. They are very useful among many data professionals because they allow us to resolve a lot of business problems. In this article, I will explain what each function does and discuss several use cases.

Tag: Minus

What Do the SQL INTERSECT and MINUS Clauses Do?

Do you know the difference between SQL’s INTERSECT and MINUS clauses and how to use them? You will find examples and explanations in this article. SQL INTERSECT and MINUS are useful clauses for quickly finding the difference between two tables and finding the rows they share. INTERSECT compares the data between tables and returns only the rows of data that exist in both tables. MINUS compares the data between tables and returns the rows of data that exist only in the first table you specify.

Tag: Miscellaneous Functions

18 Useful Important SQL Functions to Learn ASAP

Updated on: October 30th, 2023 Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike.

Tag: Monthly Sql Challenge

New MySQL Courses Are Here!

A lot of you have been waiting for new MySQL courses on LearnSQL.com – and finally, they’re here! Now you can learn everything MySQL in a simple, understandable, and fun way. We've worked a lot with these online SQL courses and created hundreds of interactive exercises to help you learn this popular SQL dialect. If you want to communicate with the world’s most popular open-source database, our MySQL courses will help you achieve that goal!

LearnSQL.com’s Monthly SQL Practice in 2022

Are you looking for ways to practice SQL? Tired of boring exercises based on unreal scenarios? We have something for you! Every month, we publish a new set of SQL practice exercises. You'll find all of them in the monthly SQL Practice. Here at LearnSQL.com, we believe the best way to learn SQL is through practice. All of our SQL courses (and there are over 30 of them!) are hands-on.

Tag: Ms Sql Server

SQL Track of the Season: SQL from A to Z in MS SQL Server

Maybe your company uses MS SQL Server and you’d like to join the data analysis team. Or maybe you want to add a new skill to your CV. Either way, our SQL Track of the Season: SQL from A to Z in MS SQL Server, will help. In this article, I’ll answer common questions about this awesome set of online MS SQL Server courses. If you’re reading this blog post, you probably already know that you should start learning SQL and working with databases.

An Overview of MS SQL Server Data Types

SQL Server data types define what can be stored in a column, local variable, expression, or parameter. It is essential to pick the right data type. Ultimately. your choice of data types affects the whole database. Read on to learn about all of the data types available in MS SQL Server. In this article, we’ll cover numerical, text, and date and time data type categories in detail. We’ll go through their syntax, storage size, and typical use cases.

How to Install MS SQL Server 2019 on Windows

Do you want to install SQL Server 2019 on your Windows PC? How about the latest version of SQL Server Management Studio? I’ll walk you through the process. Soon you’ll be writing T-SQL queries and operating on SQL Server databases! As I write this article, Microsoft SQL Server 2019 is the latest version of SQL Server. It’s the 15th version of one of the most popular database servers in the world.

Is MS SQL Server Still Worth Learning in 2024?

Updated on: March 10, 2024 MS SQL Server is an in-demand skill in today’s job market. Should you learn  MS SQL Server in 2024? In this article, I’ll answer this question. Thinking about whether you should dive into Microsoft SQL Server in 2024 – especially with so many free database alternatives available? MS SQL Server has been a go-to for handling data for ages, thanks to its solid features and reliability.

Where Can I Find Good Courses to Practice MS SQL Server?

Updated on: April 6, 2024 Begin your journey to mastering MS SQL Server with the finest practice exercises out there. Whether you are a beginner or seeking to improve your T-SQL skills, explore the top destinations for the most engaging and interactive MS SQL practice courses online. You've started learning MS SQL Server. Maybe you've done a course, watched some YouTube tutorials, and feel pretty confident in your knowledge. What now?

How to Find the Difference Between Two Datetimes in T-SQL

Problem: You have two columns of the type datetime and you want to calculate the difference between them. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between the arrival and the departure. The travel table looks like this: iddeparturearrival 12018-03-25 12:00:002018-04-05 07:30:00 22019-09-12 15:50:002019-10-23 10:30:30 32018-07-14 16:15:002018-07-14 20:40:30 42018-01-05 08:35:002019-01-08 14:00:00 Solution 1 (difference in seconds): SELECT id, departure, arrival, DATEDIFF(second, departure, arrival) AS difference FROM travel; The result is:

How to Calculate the Difference Between Two Dates in T-SQL

Problem: You have two columns of the date type and you want to calculate the difference between them. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between arrival and departure, or the number of days from arrival to departure inclusively. The travel table looks like this: iddeparturearrival 12018-03-252018-04-05 22019-09-122019-09-23 32018-07-142018-07-14 42018-01-052018-01-08 Solution: SELECT id, departure, arrival, DATEDIFF(day, departure, arrival) AS date_difference, DATEDIFF(day, departure, arrival) + 1 AS days_inclusive FROM travel; The result is:

How to Create a Table with a Foreign Key in SQL

Problem: You want to create a foreign key for a table in a database. Example: We would like to create a table named student that contains a foreign key that refers to the id column in the table city. Solution 1: Creating new table with single-column foreign key CREATE TABLE student ( id INT PRIMARY KEY, first_name VARCHAR(100) NOT NULL, last_name VARCHAR(100) NOT NULL, city_id INT FOREIGN KEY REFERENCES city(id) ); Discussion: To create a new table containing a foreign key column that references another table, use the keyword FOREIGN KEY REFERENCES at the end of the definition of that column.

How to Delete a Foreign Key Constraint in SQL

Problem: You want to delete a foreign key from a table in a database. Example: We want to remove the foreign key named fk_student_city_id from the table student. Solution: ALTER TABLE student DROP CONSTRAINT fk_student_city_id; Discussion: To delete a foreign key from a table, use the ALTER TABLE clause with the name of the table (in our example, student) followed by the clause DROP CONSTRAINT with the name of the foreign key constraint.

How to Group by Two Columns in SQL

Problem: You want to group your data by two columns so you can count some statistics. Example: In the order table, you have the columns order_date, product_id, customer_id, and number. You would like to count the number of products bought by each customer each day. The order table looks like this: order_dateproduct_idcustomer_idnumber 2023-11-25711 2023-11-251213 2023-11-265312 2023-11-26124 2023-11-26321 2023-11-261627 2023-11-26332 2023-11-27631 Solution: SELECT order_date, customer_id, SUM(number) AS products_number FROM order GROUP BY order_date, customer_id; The result is:

How to Calculate a Square Root in SQL

Problem: You want to find the square root of a number in SQ:. Example: You want to compute the square root of all numbers in the column number from the table data. number 9 2 1 0.25 0 -4 Solution: SELECT number, SQRT(number) AS square_root FROM data; The result is:

How to Group by Year in T-SQL

Problem: You want to group your data by year in SQL Server database. Example: One of the columns in your data is transaction_date. It contains a date. You would like to group all your data by year and calculate the total money earned each year. The data table looks like this: transaction_datemoney 2022-03-251700 2023-09-12100 2022-07-141200 2022-01-05400 2023-06-082000 2021-03-061500 Solution 1: Displaying the year and the money earned SELECT YEAR(transaction_date) AS year, SUM(money) AS money_earned FROM data GROUP BY YEAR(transaction_date); The result is:

How to Make a Column Unique in SQL?

Problem: You would like to make a column unique in a given table in a database. Example: We would like to make the column name unique in the table product. The query below presents one way to do it. Solution 1: Creating new table with a UNIQUE constraint CREATE TABLE product ( id INT NOT NULL PRIMARY KEY, name VARCHAR(100) UNIQUE, producer VARCHAR(100), category VARCHAR(100) ); Discussion: In this example a given column (the column name) was made unique by adding the clause UNIQUE at the end of the column definition (name VARCHAR(100) UNIQUE).

How to remove a unique constraint in SQL?

Problem: You would like to remove a unique constraint from the column/columns in a table in a database. Example: We would like to drop the unique constraint in the table product from the column name. The statement below shows how to do it. Solution ALTER TABLE product DROP CONSTRAINT UQ_product_name In this example the table product is altered by using the ALTER TABLE clause. After this clause you enter the name of the table (in our example: product) and the clause DROP CONSTRAINT with the name of the unique constraint you want to remove.

How to Get Yesterday’s Date in T-SQL

Problem: You would like to display yesterday's date (without time) in an SQL Server database. Solution: SELECT DATEADD(day, -1, CAST(GETDATE() AS date)) AS YesterdayDate; Assuming today is 2020-09-24, the result is: yesterday_date 2020-09-23 Discussion: To get yesterday's date, you need to subtract one day from today's date. Use GETDATE() to get today's date (the type is datetime) and cast it to date.

How to Add Days to a Date in T-SQL

Problem: You’d like to add a given number of days to a date in T-SQL. Example: Our database has a table named Flight with data in the columns Code and DepartureDate. CodeDepartureDate LT20302023-02-20 GH11002023-03-01 SR54672023-12-30 Let’s change the departure date for all flights, adding two days to the current departure date. Solution: We will use the DATEADD() function to specify the unit of time to add, define how much to add, and select the date to change.

How to Change Date and Time Formats in T-SQL

Problem: You’d like to change the format of a date field or value in a SQL Server database. Example: Our database has a table named Patient with data in the columns Id, FirstName, LastName, and RegistrationDate. IdFirstNameLastNameRegistrationDate 1JaneWilliams2019-06-20 2GabrielBrown2019-02-02 3LoraFolk2016-11-05 Let’s change the format of each patient’s registration date. We’ll put the name of the weekday first, followed by the month day and name and a 4-digit year (e.

How to Get Current Date & Time in T-SQL (No Time Zone)

Problem: You’d like to get the current date and time in T-SQL, but you don’t want the time zone offset. Solution: We’ll use GETDATE(), CURRENT_TIMESTAMP, and SYSDATETIME() to get the current date and time without the time zone offset. The first two functions allow us to get the current time with a lower precision. (GETDATE() is a T-SQL function, while CURRENT_TIMESTAMP is a SQL standard function; both functions return the same data type).

How to Get the Current Date (Without Time) in T-SQL

Problem: You’d like to get the current date in T-SQL, but you don’t need the time. Solution: We’ll use the GETDATE() function to get the current date and time. Then we’ll use the CAST() function to convert the returned datetime data type into a date data type. SELECT CAST( GETDATE() AS Date ) ; Here’s the result of the query: 2019-08-17 Discussion: To get the current date and time in SQL Server, use the GETDATE() function.

How to Get the Day from a Date in T-SQL

Problem: You’d like to get the number of day from a date field in a SQL Server database. For example, from the date of February 27, 2023, you'd like to get the number 27. Example: Our database has a table named MedicalVisit with data in the columns Id, FirstName, LastName, and VisitDate. IdFirstNameLastNameVisitDate 1JaneMiller2019-11-17 2AlexSmith2019-11-20 3WilliamBrown2019-11-20 4AliceThomas2019-11-05 For each patient, let’s find the day of the medical visit.

How to Get the Last Day of the Month in T-SQL

Problem: You’d like to find the last day of the month for a specific date in T-SQL. Example: Our database has a table named Furniture with data in the columns Id, Name, and PurchaseDate. IdNamePurchaseDate 1sofa2019-02-10 2desk2019-04-01 3bookcase2019-05-20 Let’s get products’ names and purchase dates and the last day of the month when these items were purchased.

How to Get the Month from a Date in T-SQL

Problem: You’d like to get the month from a date field in a SQL Server database. Example: Our database has a table named Furniture with data in the columns Id, Name, and ProducedDate. IdNameProducedDate 1sofa2018-01-10 2chair2018-01-05 3desk2018-06-20 4bookcase2018-11-15 Let’s get the month from each product’s ProducedDate and find out which furniture was produced in a given month.

How to Get the Year from a Date in T-SQL

Problem: You’d like to get the year from a date field in a SQL Server database. Example: Our database has a table named Children with data in the columns Id, FirstName, LastName, and BirthDate. IdFirstNameLastNameBirthDate 1JaneSmith2018-06-20 2GaryBrown2010-02-02 3LoraAdams2014-11-05 Let’s get the year from each child’s birthdate. Solution: We’ll use the YEAR() function. Here’s the query you would write:

How to Subtract 30 Days from a Date in T-SQL

Problem: You’d like to get the date 30 days before a given date in T-SQL. Example: Our database has a table named Computer with data in the columns Id, Name, and PurchaseDate. IdNamePurchaseDate 1Sony GX10002019-01-20 2Samsung LX20002019-04-15 3Dell K802019-08-30 Let’s get the name of each computer and the date 30 days before its purchase date.

How to Filter Records with Aggregate Function AVG

Problem: You want to filter groups of rows in by the average value of a given column. Example: Our database has a table named product with data in the following columns: id, name, store and price. idnamestoreprice 1milkGreen Shop2.34 2breadClark’s Grocery3.56 3breadSuper Market4.15 4milkSuper Market1.80 5breadGrocery Amanda2.26 6milkViolet Grocery3.45 7milkClark’s Grocery2.10 8breadViolet Grocery2.

How to Filter Records with Aggregate Function COUNT

Problem: You want to find groups of rows with a specific number of entries in a group. Example: Our database has a table named product with data in the following columns: id, name and category. idnamecategory 1sofafurniture 2glovesclothing 3T-Shirtclothing 4chairfurniture 5deskfurniture 6watchelectronics 7armchairfurniture 8skirtclothing 9radio receiverelectronics Let’s find the category of products with more than two entries.

How to Filter Records with Aggregate Function SUM

Problem: You need to filter groups of rows by the sum of a given column. Example: Our database has a table named company with data in the following columns: id, department, first_name, last_name, and salary. iddepartmentfirst_namelast_namesalary 1marketingLoraBrown2300 2financeJohnJackson3200 3marketingMichaelThomson1270 4productionTonyMiller6500 5productionSallyGreen2500 6financeOlivierBlack3450 7productionJenifferMichelin2800 8marketingJeremyLorson3600 9marketingLouisSmith4200 Let’s find the names of departments that have sums of salaries of its employees less than 7000.

How to Filter Rows without NULL in a column

Problem: You want to find records without a NULL in a column. Example: Our database has a table named product with data in three columns: id, name, and price. idnameprice 1butterNULL 2milk2.35 3bread3.25 4cheeseNULL Let’s find the names and prices of products that have a price (without a NULL). Do this by using the IS NOT NULL operator.

How to Find Records with NULL in a Column

Problem: You want to find records with NULL in a column. Example: Our database has a table named children with data in four columns: id, first_name, middle_name, and last_name. idfirst_namemiddle_namelast_name 1JohnCarlJackson 2TomNULLThomson 3LisaAliceNULL 4AnneNULLSmith Let’s find the id, first name, and last name of children without a middle name (NULL in column middle_name). We use the IS NULL operator for this. Solution: SELECT id, first_name, last_name FROM children WHERE middle_name IS NULL; Here’s the result:

How to Find Rows with Maximum Value

Problem: You want to find rows which store the largest numeric value in a given column. Example: Our database has a table named student with data in the following columns: id, first_name, last_name, and grade. You want to find the students who have the highest grades. idfirst_namelast_namegrade 1LisaJackson3 2GaryLarry5 3TomMichelin2 4MartinBarker2 5EllieBlack5 6MarySimpson4 Solution: SELECT id, first_name, last_name, grade FROM student WHERE grade = (SELECT MAX(grade) FROM student); Here’s the result:

How to Find Rows with Minimum Value

Problem: You want to find rows which store the smallest numeric value in a column. Example: Our database has a table named weather with data in the following columns: id, city, and temperature. You want to find cities with the lowest temperature. idcitytemperature 1Houston23 2Atlanta20 3Boston15 4Cleveland15 5Dallas34 6Austin28 Solution: SELECT id, city, temperature FROM weather WHERE temperature = (SELECT MIN(temperature) FROM weather); Here’s the result:

How to Convert a String to Uppercase in SQL

Problem: You would like to convert a string to uppercase in SQL. Example: Our database has a table named questionnaire with data in the following columns: id, first_name, last_name, and favorite_car. idfirst_namelast_namefavorite_car 1AlanJacksonHonda Civic 2ElisaThomsonTOYOTA Camry 3MaryMartinesNissan rogue 4ChrisBrownford focus 5AdamSpringRam PICKUP Our table stores the make and model of the favorite car for each person who filled out our questionnaire.

How to Find the Average of a Numeric Column in SQL

Problem: You’d like to calculate the average of numbers stored in a column. Example: Our database has a table named sale with data in the following columns: id, city, year, and amount. idcityyearamount 1Los Angeles20172345.50 2Chicago20181345.46 3Annandale2016900.56 4Annandale201723230.22 5Los Angeles201812456.20 6Chicago201789000.40 7Annandale201821005.77 8Chicago20162300.89 Let’s calculate the average sales, regardless of city or year.

How to Find the Average of a Numeric Column in SQL

Problem: You’d like to calculate the average of numbers stored in a column. Example: Our database has a table named sale with data in the following columns: id, city, year, and amount. idcityyearamount 1Los Angeles20172345.50 2Chicago20181345.46 3Annandale2016900.56 4Annandale201723230.22 5Los Angeles201812456.20 6Chicago201789000.40 7Annandale201821005.77 8Chicago20162300.89 Let’s calculate the average sales, regardless of city or year.

How to Find the Maximum Value of a Numeric Column in SQL

Problem: You’d like to find the maximum value of a numeric column. Example: Our database has a table named product with data in the following columns: id, name, year, and items. idnameyearitems 1bread roll2018345 2chocolate2017123 3butter201934 4bread roll2019456 5butter201856 6butter201778 7chocolate201987 8chocolate201876 Let’s find the maximum number of items sold over all years.

How to Find the Minimum Value of a Column in SQL

Problem: You’d like to find the smallest numeric value in a column. Example: Our database has a table named employment with data in the following columns: id, first_name, last_name, department, and salary. idfirst_namelast_namedepartmentsalary 1EllieMartinesmarketing1200 2MartinJohnsonfinance2300 3MichaelJacobsproduction1100 4StephenKowalskimarketing4300 5StanleyMillermarketing3500 6JenyBrownfinance5000 7MargaretGreenmarketing1500 8LisaThomasproduction2800 Let’s find the lowest salary among all employees.

How to Number Rows in SQL

Problem: You would like to give each row in the result table a separate number. Example: Our database has a table named furniture with data in the following columns: code (primary key) and name. codename 101bed 202sofa 333chair 123bookcase 235table 766desk The furniture table stores the name of pieces of furniture that we want to number.

How to Remove Leading and Trailing Spaces in T-SQL

Problem: You’d like to remove a spaces or a specific characters from the beginning and end of a string in T-SQL. Example: Our database has a table named company with data in two columns: id and name. idname 1' Super Market ' 2'Green shop ' 3' Modern Bookshop' Let’s trim the name of each company to remove the unnecessary space at the beginning and end.

What’s the Difference Between RANK and DENSE_RANK in SQL?

Problem: You want to compare the rankings produced by RANK and DENSE_RANK and add them as new columns to a table. Example: Our database has a table named sales_assistant with data in the following columns: id (primary key), first_name, last_name, month, and sold products. idfirst_namelast_namemonthsold products 1LisaBlack 52300 2MaryJacobs52400 3LisaBlack 62700 4MaryJacobs62700 5AlexSmith 62900 6MaryJacobs71200 7LisaBlack 71200 8AlexSmith 71000 Let’s display each sales assistant’s first and last name and number of sold products.

How to Add Rankings with DENSE_RANK() in SQL

Problem: You want to add a ranking position to rows consecutively, even if the rows have the same values. Example: Our database has a table named competition with data in the following columns: id (primary key), first_name, last_name, and score. idfirst_namelast_namescore 11JohnThomas345 14MaryJohnson222 16LisaBrown154 23AlanBlake222 32ChrisTaylor154 Let’s display all details about students: their last name, first name, and scores sorted by score in descending order.

How to Floor Numbers in SQL

Problem: You want to round a number down to the nearest integer. Example: Our database has a table named employee with data in the following columns: id, first_name, last_name, and hours_worked (for the current month). idfirst_namelast_namehours_worked 1AlanWatson95 2LisaBlack225 3LauraWilliams104 Let’s show the first and last name of each employee along with the number of days they worked.

How to Round Numbers in SQL

Problem: You want to round a number to a specific number of decimal places in SQL. Example: Our database has a table named product with data in the following columns: id, name, and price_net. idnameprice_net 1bread2.34 2croissant1.22 3roll0.38 Suppose there’s a tax of 24% on each product, and you’d like to compute the gross price of each item (i.e., after taxes) and round the value to two decimal places.

How to Round Up a Number to the Nearest Integer in SQL

Problem: You want to round up a number to the nearest integer in SQL. Example: Our database has a table named rent with data in the following columns: id, city, area, and bikes_for_rent. idcityareabikes_for_rent 1Los Angeles1302.151000 2Phoenix1340.69500 3Fargo126.44101 Let’s show each city’s name along with the ratio of its area to the number of bikes for rent.

How to Use LIKE in SQL

Problem: You need to search for specific patterns (certain combinations of letters or numbers) within text data in your database. We'll show you how to use the LIKE operator in SQL to: Find city names starting with S Find city names with exactly five characters Find city names starting with S and with o as the second-to-last character You'll also learn how to use LIKE and wildcard operators in SQL to find your own patterns in text data in your database.

How to Count the Number of Rows in a Table in SQL

Problem: You’d like to determine how many rows a table has. Example: Our database has a table named pet with data in the following columns: id, eID (electronic identifier), and name. ideIDname 123456sparky 223457mily 3NULLlessy 4NULLcarl 534545maggy Let’s count all rows in the table. Solution: COUNT(*) counts the total number of rows in the table:

How to Replace Part of a String in SQL

Problem: You’d like to replace part of a string with another string. Example: Our database has a table named investor with data in the following columns: id, company, and phone. idcompanyphone 1Big Market123–300-400 3The Sunny Restaurant123–222-456 4My Bank123-345-400 We’d like to change the phone number format for each company by replacing the hyphen character with a space.

How to Sum Values of a Column in SQL?

Problem: You’d like to sum the values of a column. Example: Our database has a table named game with data in the following columns: id, player, and score. idplayerscore 1John134 2Tom 146 3Lucy20 4Tom 118 5Tom 102 6Lucy90 7Lucy34 8John122 Let’s find the total score obtained by all players. Solution: SELECT SUM(score) as sum_score FROM game; Here’s the result:

How to Count Distinct Values in SQL

Problem: You’d like to count how many different non-NULL values there are in a given column. Example: Our database has a table named customer with data in the following columns: id, first_name, last_name, and city. idfirst_namelast_namecity 1JohnWilliamsChicago 2TomBrownAustin 3LucyMillerChicago 4EllieSmithDallas 5BrianJonesAustin 6AllanDavisNULL Let’s find the number of different (and non-NULL) cities.

How to Eliminate Duplicate Rows in SQL

Problem: You’d like to eliminate any duplicate rows from the result set of a query so that each row appears only once. Example: Our database has a table named clothes with data in the following columns: id, name, color, and year_produced. idnamecoloryear_produced 1T-shirtyellow2015 2jacketblue2016 3jeansblack2015 4jacketblue2015 5jacketgreen2016 6jacketyellow2017 7hatyellow2017 Let’s get the non-repeated names and colors of clothes produced before 2017.

How to Find Duplicate Rows in SQL?

Problem: You have duplicate rows in your table, with only the IDs being unique. How do you find those duplicate entries? Example: Our database has a table named product with data in the following columns: id, name, and category. idnamecategory 1steakmeat 2cakesweets 3steakmeat 4porkmeat 5cakesweets 6cakesweets Let’s find duplicate names and categories of products.

How to Handle Divide by Zero In SQL

Problem: You want to perform division in your SQL query, but the denominator is an expression that can be zero. The database will give you an error when the denominator is in fact zero. Example: Our database has a table named investor_data with data in the following columns: id, investor_year, price_per_share, income, and expenses. idinvestor_yearprice_per_shareincomeexpenses 120162032002300 2201713020002000 3201840200100 420191559004900 Let’s divide the price per share by the difference between income and expenses to determine the P/E ratio (price-earnings ratio) for each year.

How to Join on Multiple Columns

Problem: You want to join tables on multiple columns by using a primary compound key in one table and a foreign compound key in another. Example: Our database has three tables named student, enrollment, and payment. The student table has data in the following columns: id (primary key), first_name, and last_name. idfirst_namelast_name 1EllieWillson 2TomBrown 3SandraMiller The enrollment table has data in the following columns: primary key (student_id and course_code), is_active, and start_date.

How to Multiply Two Columns in SQL

Problem: You want to multiply values from two columns of a table. Example: Our database has a table named purchase with data in the following columns: id, name, price, quantity, and discount_id. idnamepricequantitydiscount_id 1pen731 2notebook582 3rubber1131 4pencil case2423 Let’s multiply the price by the quantity of the products to find out how much you paid for each item in your order.

How to Order By Two Columns in SQL?

Problem: You need to display records from a given table sorted by two columns. Example: Our database has a table named employee with the following columns: id, first_name, last_name, and salary. idfirst_namelast_namesalary 1LisaUlman3000 2AdaMuller2400 3ThomasGreen2400 4MichaelMuller3000 5MaryGreen2400 Let’s display all information for each employee but sort the records according to salary in descending order first and then by last name in ascending order.

How to Order by Count in SQL?

Problem: You aggregated data into groups, but you want to sort the records in descending order by the number of elements in the groups. Example: Our database has a table named user with data in the following columns: id, first_name, last_name, and country. idfirst_namelast_namecountry 1LisaWilliamsEngland 2GaryAndersPoland 3TomWilliamsPoland 4MichaelBrownFrance 5SusanSmithUSA 6AnneJonesUSA 7EllieMillerPoland Let’s create a report on our users.

How to Order Alphabetically in SQL

Problem: You want to display records from a table in alphabetical or reverse-alphabetical order according to given column. Example: Our database has a table named customer. The customer table contains data in the id, first_name, and last_name columns. id first_name last_name 1 Susan Thomas 2 John Michael 3 Tom Muller Let’s display each customer’s information, sorted in ascending order by their last name.

14 Differences Between Standard SQL and Transact-SQL

In my last article, I roughly described how standard SQL differs from T-SQL and who should learn which. Now I'd like to focus on the syntax differences and illustrate these differences with examples. If you think T-SQL is an extension implementing all the features from standard SQL, you aren't right. However, in SQL Server you will find almost all the features of the SQL standard. In this article you will find examples of some of the differences in syntax between standard SQL and Transact-SQL.

What's the Difference Between SQL and T-SQL?

If you are beginning to learn SQL and are confused by the differences between standard SQL and other similar languages like T-SQL, this article will help make things clear. You’ll not only learn about the difference between SQL and T-SQL but also find explanations concerning which topics would be better to start learning first: standard SQL or something more specific like MS SQL Server. What is Standard SQL? SQL (Structured Query Language) is a basic ANSI/ISO standard programming language designed to operate on data stored in relational databases.

Microsoft SQL Server Pros and Cons

Thinking about using Microsoft SQL Server? If so, you’re in the right place. In this article, we’ll go over the pros and cons of Microsoft SQL Server and evaluate the platform from both a company’s and a data specialist’s perspective. What Is Microsoft SQL Server? Before diving into the pros and cons of Microsoft SQL Server, I’ll explain what it is. In technical terms, it is a relational database management system (RDBMS) developed by Microsoft.

Microsoft SQL Server 2017 Installation Step by Step

Microsoft SQL Server is one of the most popular professional database servers on the market. In this guide, I’ll show you all SQL Server 2017 installation steps to help you install it on the Windows operating system together with SQL Management Studio. If you want to learn T-SQL, the dialect of SQL used in SQL Server, check out our SQL from A to Z in MS SQL Server track.

Tag: Mysql

How to Install MySQL on Ubuntu

Looking to install MySQL on Ubuntu? Delve into the world of efficient data management with this comprehensive guide. From updating your package list to securing your installation and ensuring smooth configurations, these step-by-step instructions will help you seamlessly set up MySQL on your Ubuntu system. If you’re reading this article, you’re seriously interested in working with data. What you need is a suitable tool to make it happen. If you’re considering installing MySQL on an Ubuntu Linux system, you may wonder if this combination is a good choice.

MySQL Date Functions: Complete Analyst’s Guide

Master MySQL date functions and acquire a powerful tool to work with date and time information in your data analyses. Working with date and time data is an essential part of data analysis. Here are just three examples: Analyzing historical time series data is crucial for discovering trends and making reliable forecasts based on chronological information. Stock market analysis examines time series data extensively, especially when automated trading algorithms are employed.

Integrating SQL with Python for Data Analysis

Integrating SQL with Python isn’t difficult. The two tools work together to combine the information-processing power of relational databases with the flexibility of a programming language. In this article, I will discuss the benefits of data analysis using SQL and Python, with real-world coding examples. Why do most of the best data analysis tools on the market – such as Tableau and Power BI – include both SQL and Python in their toolboxes?

MySQL Practice: Best Exercises for Beginners

These 15 MySQL exercises are especially designed for beginners. They cover essential topics like selecting data from one table, ordering and grouping data, and joining data from multiple tables This article showcases beginner-level MySQL practice exercises, including solutions and comprehensive explanations. If you need to practice … Selecting data from one table Ordering and grouping data Joining data from multiple tables … these 15 tasks are just for you!

An Overview of MySQL Window Functions

MySQL window functions are very helpful when you want to create meaningful reports with SQL. In this article, we’ll demonstrate the most common window functions in MySQL and explain how to use them. MySQL 8.0 introduced a new feature: window functions. These functions are very useful to data analysts and anyone who creates reports using MySQL. Using them, you can easily compute moving averages, cumulative sums, and other calculations over specified subsets of your data.

MySQL Cheat Sheet

Welcome to the MySQL cheat sheet! Whether you're just starting out with MySQL or you're a seasoned professional looking for a quick reference, this guide is tailor-made for you. This MySQL Cheat Sheet provides a concise and handy reference to the most commonly used MySQL commands and functionalities. It spans a range of topics, from connecting to a MySQL server and managing database contents, to the basic syntax for table creation and modification.

Best MySQL Courses for Beginners

SQL is among the most important languages when it comes to dealing with huge amounts of data. If your job includes analyzing or collecting data and you feel that an Excel file is not enough, you need to learn or develop your SQL skills. And if you learn SQL, you also need to know one of its most popular dialects - MySQL. If you've made the decision to learn SQL, you've come to the right place.

How to Export Data from MySQL into a CSV File

A database is a primary platform for working with data and storing data. But often, you must take your data out of the database. Read on to find out how to export data from MySQL database into a CSV file. In this article, we’ll demonstrate how to export data into a CSV file. We’ll start by introducing what a CSV file is and why we use it. Then, we’ll export data from a MySQL database into a CSV file.

Top 10 MySQL Interview Questions And Answers

You learned SQL and now you want to use this valuable skill to get a better job. Now it’s time to prepare for the job interview. We’ve got ten MySQL interview questions and answers to help you with that. In today's hyperconnected world, knowing how to deal with it has become a necessary skill. That’s why you probably learned (or want to learn) SQL: either your job requires it or you realized that you need SQL to get a better job.

An Overview of SQL Text Functions in MySQL

Do you work in MySQL as a data analyst? Then you should know how to use its text functions – data analysts don’t work only with numbers. Reporting requires computations, data classification, and label creation, and you can do all of that in MySQL.  In this article, I’ll explain several of the most common and useful MySQL text functions by discussing what they do and showing how they do it.

Top 5 MySQL Query Tools

Are you looking for a software solution that will make working with the MySQL database even easier? In this article, I’ll tell you about five highly recommended query tools that will save you time. MySQL may already be familiar to you as the most popular open-source relational database management system (DBMS). It works in most applications, which is why the last Stack Overflow report rated MySQL as the most used database.

An Overview of MySQL Data Types

What data types are available in a MySQL database? In this article, you’ll learn about numeric data types, text data types, and much more! You may have seen our article about data types in SQL. Here, we focus on the MySQL data types. We will discuss the most commonly used ones: numeric, text, and date and time. If you are interested in the topic, be sure to check out our Data Types in SQL course.

SQL Date and Time Functions in 5 Popular SQL Dialects

Are you confused by all the date and time functions used across different SQL dialects? In this article, I summarize the date and time data types used in PostgreSQL, Oracle, SQLite, MySQL, and T-SQL. I also provide examples with the key SQL date and time functions used across these dialects. It’s time to become date and time gurus! Do you want to calculate how often employees are running late for work?

How to Order by Date in MySQL

Problem: You want to sort the rows by date in MySQL. Example 1: The exam table has two columns, subject and exam_date. subjectexam_date Mathematics2019-12-19 English2020-01-08 Science2020-01-05 Health2020-01-05 ArtNULL You want to sort the rows by exam_date. Solution: SELECT * FROM exam ORDER BY exam_date; The result looks like this (the rows are sorted in ascending order by exam_date):

How to Calculate Timestamp Difference in MySQL

Problem: You have two columns of the type timestamp and you want to calculate the difference between them. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between the arrival and the departure. The travel table looks like this: iddeparturearrival 12018-03-25 12:00:002018-04-05 07:30:00 22019-09-12 15:50:002019-10-23 10:30:30 32018-07-14 16:15:002018-07-14 20:40:30 42018-01-05 08:35:002019-01-08 14:00:00 Solution 1 (difference in days, hours, minutes, or seconds): SELECT id, departure, arrival, TIMESTAMPDIFF(SECOND, departure, arrival) AS difference FROM travel; The result is:

How to Calculate the Difference Between Two Dates in MySQL

Problem: You have two columns of the date type and you want to calculate the difference between them. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between arrival and departure, or the number of days from arrival to departure inclusively. The travel table looks like this: iddeparturearrival 12018-03-252018-04-05 22019-09-122019-09-23 32018-07-142018-07-14 42018-01-052018-01-08 Solution: SELECT id, departure, arrival, DATEDIFF(arrival, departure) AS date_difference, DATEDIFF(arrival, departure) + 1 AS days_inclusive FROM travel; The result is:

How to Create a Table with a Foreign Key in SQL

Problem: You want to create a foreign key for a table in a database. Example: We would like to create a table named student that contains a foreign key that refers to the id column in the table city. Solution 1: Creating new table with single-column foreign key CREATE TABLE student ( id INT PRIMARY KEY, first_name VARCHAR(100) NOT NULL, last_name VARCHAR(100) NOT NULL, city_id INT FOREIGN KEY REFERENCES city(id) ); Discussion: To create a new table containing a foreign key column that references another table, use the keyword FOREIGN KEY REFERENCES at the end of the definition of that column.

How to Delete a Foreign Key Constraint in SQL

Problem: You want to delete a foreign key from a table in a database. Example: We want to remove the foreign key named fk_student_city_id from the table student. Solution: ALTER TABLE student DROP CONSTRAINT fk_student_city_id; Discussion: To delete a foreign key from a table, use the ALTER TABLE clause with the name of the table (in our example, student) followed by the clause DROP CONSTRAINT with the name of the foreign key constraint.

How to Group by Two Columns in SQL

Problem: You want to group your data by two columns so you can count some statistics. Example: In the order table, you have the columns order_date, product_id, customer_id, and number. You would like to count the number of products bought by each customer each day. The order table looks like this: order_dateproduct_idcustomer_idnumber 2023-11-25711 2023-11-251213 2023-11-265312 2023-11-26124 2023-11-26321 2023-11-261627 2023-11-26332 2023-11-27631 Solution: SELECT order_date, customer_id, SUM(number) AS products_number FROM order GROUP BY order_date, customer_id; The result is:

How to Calculate a Square Root in SQL

Problem: You want to find the square root of a number in SQ:. Example: You want to compute the square root of all numbers in the column number from the table data. number 9 2 1 0.25 0 -4 Solution: SELECT number, SQRT(number) AS square_root FROM data; The result is:

How to Group by Year in SQL

Problem: You want to group your data by year in SQL. Example 1: One of the columns in your data is transaction_date. It contains a date. You would like to group all your data by year and calculate the total money earned each year. The data table looks like this: transaction_datemoney 2018-03-251700 2019-09-12100 2018-07-141200 2018-01-05400 2019-06-082000 2020-03-061500 Solution 1: Displaying the year and the money earned SELECT EXTRACT(year FROM transaction_date) AS year, SUM(money) AS money_earned FROM data GROUP BY EXTRACT(year FROM transaction_date); The result is:

How to Make a Column Unique in SQL?

Problem: You would like to make a column unique in a given table in a database. Example: We would like to make the column name unique in the table product. The query below presents one way to do it. Solution 1: Creating new table with a UNIQUE constraint CREATE TABLE product ( id INT NOT NULL PRIMARY KEY, name VARCHAR(100) UNIQUE, producer VARCHAR(100), category VARCHAR(100) ); Discussion: In this example a given column (the column name) was made unique by adding the clause UNIQUE at the end of the column definition (name VARCHAR(100) UNIQUE).

How to Get Yesterday’s Date in MySQL

Problem: You would like to display yesterday's date (without time) in a MySQL database. Solution: SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS yesterday_date; Assuming today is 2020-09-24, the result is: yesterday_date 2020-09-23 Discussion: To get yesterday's date, you need to subtract one day from today's date. Use CURDATE() to get today's date. In MySQL, you can subtract any date interval using the DATE_SUB() function.

How to Add Days to a Date in MySQL

Problem: You’d like to add days to a date in a MySQL database. Example: Our database has a table named trip with data in the columns id, city, and start_date. idcitystart_date 1Chicago2023-06-22 2Houston2023-07-15 3Dallas2023-08-30 4Austin2023-09-23 Let’s add two days to the start dates and get the trip cities with the new start dates.

How to Add Time to a Datetime Value in MySQL

Problem: You’d like to add a certain amount of time to a datetime value in a MySQL database. Example: Our database has a table named flight_schedule with data in the columns flight, aircraft, and arrival_datetime. flightaircraftarrival_datetime EK10L12012019-04-20 15:15:00 AY12K20012019-03-31 20:10:00 LA105F2052019-08-03 11:15:00 LH30K2562019-07-01 12:47:00 For each flight, let’s get the flight code, aircraft code, and a new arrival date and time.

How to Change Datetime Formats in MySQL

Problem: You’d like to change the format of date and time data in a MySQL database. Example: Our database has a table named student_platform with data in the columns id, first_name, last_name, and registration_datetime. idfirst_namelast_nameregistration_datetime 1LoraLorens2019-02-23 12:04:23 2AnneSmith2018-07-10 10:12:15 3TomJackson2019-03-09 08:20:33 4RichardWilliams2018-09-30 06:07:34 For each student, let’s get their first name, last name, and registration date and time.

How to Change Seconds to a Time Value in MySQL

Problem: You’d like to display a number of seconds as a time value in hours, minutes, and seconds in MySQL. Example: Our database has a table named athlete_score with data in the columns id, first_name, last_name, and score_seconds. idfirst_namelast_namescore_seconds 1EmilyWatson1124 2TomGarcia987 3GaryMartinez1003 4JamesAnderson1233 For each athlete, let’s get their first and last names and their record time from the seconds_record column.

How to Find the Last Day of a Month in MySQL

Problem: You’d like to get the date of the last day of the month for a date in a MySQL database. Example: Our database has a table named car_sales with data in the columns id, make, model, and sale_date. idmakemodelsale_date 1FordKa2019-02-01 2ToyotaYaris2019-08-15 3OpelCorsa2019-06-22 For each car, let’s get the make and model and the last day of the month in which the car was sold.

How to Find the Number of Days Between Two Dates in MySQL

Problem: You’d like to get the difference, in days, between two dates in a MySQL database. Example: Our database has a table named food with data in the columns id, name, purchase_date, and expiration_date. idnamepurchase_dateexpiration_date 1bread 2019-07-202019-08-22 2butter2018-07-302019-08-10 3milk 2019-01-122019-01-13 4yogurt2019-02-252019-02-24 For each food product, let’s get the name of the product and the number of days between its expiration and purchase dates. Solution: We’ll use the DATEDIFF() function.

How to Get the Current Date and Time in MySQL

Problem: You’d like to get the current date and time for a MySQL database. Solution: We’ll use one of two functions, CURRENT_TIMESTAMP or NOW(), to get the current date and time. SELECT CURRENT_TIMESTAMP ; Here’s the result of the query: 2023-08-15 11:13:17 Discussion: The CURRENT_TIMESTAMP function in the MySQL database returns the current date and time (i.e. the time for the machine running that instance of MySQL). It is given as a value in the YYYY-MM-DD hh:mm:ss format.

How to Get the Date from a Datetime Column in MySQL

Problem: You’d like to get the date from a date and time column in a MySQL database. Example: Our database has a table named travel with data in the columns id, first_name, last_name, and timestamp_of_booking. idfirst_namelast_nametimestamp_of_booking 1LisaWatson2019-04-20 14:15:34 2TomSmith2019-03-31 20:10:14 3AndyMarkus2019-08-03 10:05:45 4AliceBrown2019-07-01 12:47:54 For each traveler, let’s get their first and last name and the booking date only.

How to Get the Month from a Date in MySQL

Problem: You’d like to get the month from a date/datetime column in a MySQL database. Example: Our database has a table named apartment_rental with data in the columns id, address, floor, and start_date. idaddressfloorstart_date 1700 Oak Street22019-03-20 2295 Main Street32019-05-31 3506 State Road12019-01-03 43949 Route 3112019-02-01 For each available apartment, get the address, the floor, and the month when it’s available.

How to Get the Year from a Datetime Column in MySQL

Problem: You’d like to get the year from a date/datetime column in a MySQL database. Example: Our database has a table named conference with data in the columns id, name, and start_datetime. idnamestart_datetime 1Social Media World2019-02-20 14:15:34 2Mobile World 20172017-08-31 20:10:14 3Electronics Show2018-04-03 10:05:45 4Tech Asia 20192019-01-01 12:47:54 For each conference, let’s get its name and year.

How to Concatenate Strings in SQL

Problem: You want to join strings from two columns of a table into one. Example: Our database has a table named student with data in the following columns: id, first_name and last_name. idfirst_namelast_name 1LoraSmith 2EmilBrown 3AlexJackson 4MartinDavis Let’s append the first name to the last name of the student in one string. Use a space between each name.

How to Filter Records with Aggregate Function AVG

Problem: You want to filter groups of rows in by the average value of a given column. Example: Our database has a table named product with data in the following columns: id, name, store and price. idnamestoreprice 1milkGreen Shop2.34 2breadClark’s Grocery3.56 3breadSuper Market4.15 4milkSuper Market1.80 5breadGrocery Amanda2.26 6milkViolet Grocery3.45 7milkClark’s Grocery2.10 8breadViolet Grocery2.

How to Filter Records with Aggregate Function COUNT

Problem: You want to find groups of rows with a specific number of entries in a group. Example: Our database has a table named product with data in the following columns: id, name and category. idnamecategory 1sofafurniture 2glovesclothing 3T-Shirtclothing 4chairfurniture 5deskfurniture 6watchelectronics 7armchairfurniture 8skirtclothing 9radio receiverelectronics Let’s find the category of products with more than two entries.

How to Filter Records with Aggregate Function SUM

Problem: You need to filter groups of rows by the sum of a given column. Example: Our database has a table named company with data in the following columns: id, department, first_name, last_name, and salary. iddepartmentfirst_namelast_namesalary 1marketingLoraBrown2300 2financeJohnJackson3200 3marketingMichaelThomson1270 4productionTonyMiller6500 5productionSallyGreen2500 6financeOlivierBlack3450 7productionJenifferMichelin2800 8marketingJeremyLorson3600 9marketingLouisSmith4200 Let’s find the names of departments that have sums of salaries of its employees less than 7000.

How to Filter Rows without NULL in a column

Problem: You want to find records without a NULL in a column. Example: Our database has a table named product with data in three columns: id, name, and price. idnameprice 1butterNULL 2milk2.35 3bread3.25 4cheeseNULL Let’s find the names and prices of products that have a price (without a NULL). Do this by using the IS NOT NULL operator.

How to Find Records with NULL in a Column

Problem: You want to find records with NULL in a column. Example: Our database has a table named children with data in four columns: id, first_name, middle_name, and last_name. idfirst_namemiddle_namelast_name 1JohnCarlJackson 2TomNULLThomson 3LisaAliceNULL 4AnneNULLSmith Let’s find the id, first name, and last name of children without a middle name (NULL in column middle_name). We use the IS NULL operator for this. Solution: SELECT id, first_name, last_name FROM children WHERE middle_name IS NULL; Here’s the result:

How to Find Rows with Maximum Value

Problem: You want to find rows which store the largest numeric value in a given column. Example: Our database has a table named student with data in the following columns: id, first_name, last_name, and grade. You want to find the students who have the highest grades. idfirst_namelast_namegrade 1LisaJackson3 2GaryLarry5 3TomMichelin2 4MartinBarker2 5EllieBlack5 6MarySimpson4 Solution: SELECT id, first_name, last_name, grade FROM student WHERE grade = (SELECT MAX(grade) FROM student); Here’s the result:

How to Find Rows with Minimum Value

Problem: You want to find rows which store the smallest numeric value in a column. Example: Our database has a table named weather with data in the following columns: id, city, and temperature. You want to find cities with the lowest temperature. idcitytemperature 1Houston23 2Atlanta20 3Boston15 4Cleveland15 5Dallas34 6Austin28 Solution: SELECT id, city, temperature FROM weather WHERE temperature = (SELECT MIN(temperature) FROM weather); Here’s the result:

How to Convert a String to Uppercase in SQL

Problem: You would like to convert a string to uppercase in SQL. Example: Our database has a table named questionnaire with data in the following columns: id, first_name, last_name, and favorite_car. idfirst_namelast_namefavorite_car 1AlanJacksonHonda Civic 2ElisaThomsonTOYOTA Camry 3MaryMartinesNissan rogue 4ChrisBrownford focus 5AdamSpringRam PICKUP Our table stores the make and model of the favorite car for each person who filled out our questionnaire.

How to Find the Average of a Numeric Column in SQL

Problem: You’d like to calculate the average of numbers stored in a column. Example: Our database has a table named sale with data in the following columns: id, city, year, and amount. idcityyearamount 1Los Angeles20172345.50 2Chicago20181345.46 3Annandale2016900.56 4Annandale201723230.22 5Los Angeles201812456.20 6Chicago201789000.40 7Annandale201821005.77 8Chicago20162300.89 Let’s calculate the average sales, regardless of city or year.

How to Find the Maximum Value of a Numeric Column in SQL

Problem: You’d like to find the maximum value of a numeric column. Example: Our database has a table named product with data in the following columns: id, name, year, and items. idnameyearitems 1bread roll2018345 2chocolate2017123 3butter201934 4bread roll2019456 5butter201856 6butter201778 7chocolate201987 8chocolate201876 Let’s find the maximum number of items sold over all years.

How to Find the Minimum Value of a Column in SQL

Problem: You’d like to find the smallest numeric value in a column. Example: Our database has a table named employment with data in the following columns: id, first_name, last_name, department, and salary. idfirst_namelast_namedepartmentsalary 1EllieMartinesmarketing1200 2MartinJohnsonfinance2300 3MichaelJacobsproduction1100 4StephenKowalskimarketing4300 5StanleyMillermarketing3500 6JenyBrownfinance5000 7MargaretGreenmarketing1500 8LisaThomasproduction2800 Let’s find the lowest salary among all employees.

How to Number Rows in SQL

Problem: You would like to give each row in the result table a separate number. Example: Our database has a table named furniture with data in the following columns: code (primary key) and name. codename 101bed 202sofa 333chair 123bookcase 235table 766desk The furniture table stores the name of pieces of furniture that we want to number.

What’s the Difference Between RANK and DENSE_RANK in SQL?

Problem: You want to compare the rankings produced by RANK and DENSE_RANK and add them as new columns to a table. Example: Our database has a table named sales_assistant with data in the following columns: id (primary key), first_name, last_name, month, and sold products. idfirst_namelast_namemonthsold products 1LisaBlack 52300 2MaryJacobs52400 3LisaBlack 62700 4MaryJacobs62700 5AlexSmith 62900 6MaryJacobs71200 7LisaBlack 71200 8AlexSmith 71000 Let’s display each sales assistant’s first and last name and number of sold products.

How to Add Rankings with DENSE_RANK() in SQL

Problem: You want to add a ranking position to rows consecutively, even if the rows have the same values. Example: Our database has a table named competition with data in the following columns: id (primary key), first_name, last_name, and score. idfirst_namelast_namescore 11JohnThomas345 14MaryJohnson222 16LisaBrown154 23AlanBlake222 32ChrisTaylor154 Let’s display all details about students: their last name, first name, and scores sorted by score in descending order.

How to Floor Numbers in SQL

Problem: You want to round a number down to the nearest integer. Example: Our database has a table named employee with data in the following columns: id, first_name, last_name, and hours_worked (for the current month). idfirst_namelast_namehours_worked 1AlanWatson95 2LisaBlack225 3LauraWilliams104 Let’s show the first and last name of each employee along with the number of days they worked.

How to Round Numbers in SQL

Problem: You want to round a number to a specific number of decimal places in SQL. Example: Our database has a table named product with data in the following columns: id, name, and price_net. idnameprice_net 1bread2.34 2croissant1.22 3roll0.38 Suppose there’s a tax of 24% on each product, and you’d like to compute the gross price of each item (i.e., after taxes) and round the value to two decimal places.

How to Round Up a Number to the Nearest Integer in SQL

Problem: You want to round up a number to the nearest integer in SQL. Example: Our database has a table named rent with data in the following columns: id, city, area, and bikes_for_rent. idcityareabikes_for_rent 1Los Angeles1302.151000 2Phoenix1340.69500 3Fargo126.44101 Let’s show each city’s name along with the ratio of its area to the number of bikes for rent.

How to Use LIKE in SQL

Problem: You need to search for specific patterns (certain combinations of letters or numbers) within text data in your database. We'll show you how to use the LIKE operator in SQL to: Find city names starting with S Find city names with exactly five characters Find city names starting with S and with o as the second-to-last character You'll also learn how to use LIKE and wildcard operators in SQL to find your own patterns in text data in your database.

How to Count the Number of Rows in a Table in SQL

Problem: You’d like to determine how many rows a table has. Example: Our database has a table named pet with data in the following columns: id, eID (electronic identifier), and name. ideIDname 123456sparky 223457mily 3NULLlessy 4NULLcarl 534545maggy Let’s count all rows in the table. Solution: COUNT(*) counts the total number of rows in the table:

How to Replace Part of a String in SQL

Problem: You’d like to replace part of a string with another string. Example: Our database has a table named investor with data in the following columns: id, company, and phone. idcompanyphone 1Big Market123–300-400 3The Sunny Restaurant123–222-456 4My Bank123-345-400 We’d like to change the phone number format for each company by replacing the hyphen character with a space.

How to Sum Values of a Column in SQL?

Problem: You’d like to sum the values of a column. Example: Our database has a table named game with data in the following columns: id, player, and score. idplayerscore 1John134 2Tom 146 3Lucy20 4Tom 118 5Tom 102 6Lucy90 7Lucy34 8John122 Let’s find the total score obtained by all players. Solution: SELECT SUM(score) as sum_score FROM game; Here’s the result:

How to Trim Strings in SQL

Problem: You’d like to remove specific characters from the beginning and end of a string in SQL. Example: Our database has a table named post with data in two columns: id and title. idtitle 1' News about dogs ' 3'Eurovision 2019 ' 4'New political climate' Let’s trim the title of each post to remove the unnecessary space at the beginning and end.

How to Count Distinct Values in SQL

Problem: You’d like to count how many different non-NULL values there are in a given column. Example: Our database has a table named customer with data in the following columns: id, first_name, last_name, and city. idfirst_namelast_namecity 1JohnWilliamsChicago 2TomBrownAustin 3LucyMillerChicago 4EllieSmithDallas 5BrianJonesAustin 6AllanDavisNULL Let’s find the number of different (and non-NULL) cities.

How to Eliminate Duplicate Rows in SQL

Problem: You’d like to eliminate any duplicate rows from the result set of a query so that each row appears only once. Example: Our database has a table named clothes with data in the following columns: id, name, color, and year_produced. idnamecoloryear_produced 1T-shirtyellow2015 2jacketblue2016 3jeansblack2015 4jacketblue2015 5jacketgreen2016 6jacketyellow2017 7hatyellow2017 Let’s get the non-repeated names and colors of clothes produced before 2017.

How to Find Duplicate Rows in SQL?

Problem: You have duplicate rows in your table, with only the IDs being unique. How do you find those duplicate entries? Example: Our database has a table named product with data in the following columns: id, name, and category. idnamecategory 1steakmeat 2cakesweets 3steakmeat 4porkmeat 5cakesweets 6cakesweets Let’s find duplicate names and categories of products.

How to Join on Multiple Columns

Problem: You want to join tables on multiple columns by using a primary compound key in one table and a foreign compound key in another. Example: Our database has three tables named student, enrollment, and payment. The student table has data in the following columns: id (primary key), first_name, and last_name. idfirst_namelast_name 1EllieWillson 2TomBrown 3SandraMiller The enrollment table has data in the following columns: primary key (student_id and course_code), is_active, and start_date.

How to Multiply Two Columns in SQL

Problem: You want to multiply values from two columns of a table. Example: Our database has a table named purchase with data in the following columns: id, name, price, quantity, and discount_id. idnamepricequantitydiscount_id 1pen731 2notebook582 3rubber1131 4pencil case2423 Let’s multiply the price by the quantity of the products to find out how much you paid for each item in your order.

How to Order By Two Columns in SQL?

Problem: You need to display records from a given table sorted by two columns. Example: Our database has a table named employee with the following columns: id, first_name, last_name, and salary. idfirst_namelast_namesalary 1LisaUlman3000 2AdaMuller2400 3ThomasGreen2400 4MichaelMuller3000 5MaryGreen2400 Let’s display all information for each employee but sort the records according to salary in descending order first and then by last name in ascending order.

How to Order by Count in SQL?

Problem: You aggregated data into groups, but you want to sort the records in descending order by the number of elements in the groups. Example: Our database has a table named user with data in the following columns: id, first_name, last_name, and country. idfirst_namelast_namecountry 1LisaWilliamsEngland 2GaryAndersPoland 3TomWilliamsPoland 4MichaelBrownFrance 5SusanSmithUSA 6AnneJonesUSA 7EllieMillerPoland Let’s create a report on our users.

How to Order Alphabetically in SQL

Problem: You want to display records from a table in alphabetical or reverse-alphabetical order according to given column. Example: Our database has a table named customer. The customer table contains data in the id, first_name, and last_name columns. id first_name last_name 1 Susan Thomas 2 John Michael 3 Tom Muller Let’s display each customer’s information, sorted in ascending order by their last name.

Referential Constraints and Foreign Keys in MySQL

Foreign keys and referential constraints allow you to set relationships between tables and modify some of the database engine’s actions. This beginner’s guide explains referential integrity and foreign key use in MySQL. One of the most important aspects of database usage is being able to trust the information you store. Database engines provide several features that help you maintain the quality of your data, like defining required columns as NOT NULL and setting an exact data type for each column.

MySQL Collations

List Collations To list all collations available in MySQL, use SHOW COLLATION; +-------------------+----------+-----+---------+----------+---------+ | Collation | Charset | Id | Default | Compiled | Sortlen | +-------------------+----------+-----+---------+----------+---------+ | big5_chinese_ci | big5 | 1 | Yes | Yes | 1 | | big5_bin | big5 | 84 | | Yes | 1 | | dec8_swedish_ci | dec8 | 3 | Yes | Yes | 1 | | dec8_bin | dec8 | 69 | | Yes | 1 | | cp850_general_ci | cp850 | 4 | Yes | Yes | 1 | | cp850_bin | cp850 | 80 | | Yes | 1 | | hp8_english_ci | hp8 | 6 | Yes | Yes | 1 | | hp8_bin | hp8 | 72 | | Yes | 1 | | koi8r_general_ci | koi8r | 7 | Yes | Yes | 1 | | koi8r_bin | koi8r | 74 | | Yes | 1 | | latin1_german1_ci | latin1 | 5 | | Yes | 1 | | latin1_swedish_ci | latin1 | 8 | Yes | Yes | 1 | | latin1_danish_ci | latin1 | 15 | | Yes | 1 | | latin1_german2_ci | latin1 | 31 | | Yes | 2 | | latin1_bin | latin1 | 47 | | Yes | 1 | | latin1_general_ci | latin1 | 48 | | Yes | 1 | .

SQL vs. Mongo query

In recent times, NoSQL databases have become a hot topic and have gained a crowd of advocates. Indeed, when NoSQL database started to arise, SQL-to-NoSQL converters arose with them as well. But unfortunately, thanks to the code conversion possibility, SQL supporters gained unquestionable evidence that in many cases the good, old SQL is much easier to use. Especially when it comes to queries. I performed a quick Google search and found plenty of nice converter tools.

MySQL's group_concat Equivalents in PostgreSQL, Oracle, DB2, HSQLDB, and SQLite

The GROUP_CONCAT() function in MySQL MySQL has a very handy function which concatenates strings from a group into one string. For example, let's take a look at the children table with data about parents' and children's names. if (typeof VertabeloEmbededObject === 'undefined') {var VertabeloEmbededObject = "loading";var s=document.createElement("script");s.setAttribute("type","text/javascript");s.setAttribute("src", "https://my.vertabelo.com/js/public-model/v1/api.js");(document.getElementsByTagName("head")[0] || document.documentElement ).appendChild(s);} parent_name child_name John Tom Michael Sylvie John Anna Michael Sophie To get the names of children of each person as a comma-separated string, you use the GROUP_CONCAT() function as follows:

Tag: New Course

Our New Interactive Course – SQL Practice: University

Are you a beginner looking for a hands-on online SQL course to solidify your skills? Or perhaps you're an SQL learner hungry for real-world applications of your new skills? LearnSQL.com, has crafted a robust practice-based learning experience to help you advance at your own pace. Here is SQL Practice: University! In today's data-driven world, mastering SQL is more than just a useful skill—it's a powerful tool that can open doors to many career opportunities.

New Course: Customer Behavior Analysis in SQL

Good news! A new SQL course is here! We’re happy to announce the release of our Customer Behavior Analysis in SQL course. Do you want to get to know your clients and better understand their needs and behavior? If so, this great interactive SQL course is for you. Discover the power of full customer lifecycle analytics in SQL and know more than your competitors. The LearnSQL.com team is happy to announce the release of a new SQL course on our platform: Customer Behavior Analysis in SQL.

Tag: Null

How to Use Comparison Operators with NULLs in SQL

The SQL NULL value serves a special purpose. It also comes with counterintuitive behaviors that can trip up SQL beginners or even experienced programmers. Learn how to avoid these problems when you use NULL with comparison operators. This article is going to help you master best practices for crafting SQL queries that work with NULL values and use comparison operators ( =, <>, <, > ) – which, if you have written any SQL queries before, you know is just about every query you will ever write!

NULL Values and the GROUP BY Clause

We've already covered how to use the GROUP BY clause and some aggregation functions like SUM(), AVG(), MAX(), MIN(), COUNT(). In this article, we will explain how the GROUP BY clause works when NULL values are involved. We will also explain about using NULLs with the ORDER BY clause. The best way to master GROUP BY and NULL in SQL is through practice. I recommend the SQL Practice track at LearnSQL.

Understanding the Use of NULL in SQL Three-Valued Logic

NULLs are necessary in relational databases, and learning to use them is fundamental to SQL success. However, NULLs should also be handled with care, as we explain in this post. In relational databases, we don’t always have a value to put in a column. For example, suppose we have a table called “persons” that has “first_name”, “last_name”, “birth_date” and “marriage_date” columns. What value will we store in the “marriage_date” column for single persons?

How to Tackle SQL NULLs: COALESCE function

It's inevitable that some data in the database has no value what in SQL is represented by the NULL keyword. "No value" here is different from zero, false, or an empty string (but with exceptions! In Oracle database, NULL is the same as string of zero length). During playing with the database, treating NULLs are becoming more and more troublesome, therefore MySQL standard provides help with some of the functions, like COALESCE.

Tag: Null Values

NULL Values and the GROUP BY Clause

We've already covered how to use the GROUP BY clause and some aggregation functions like SUM(), AVG(), MAX(), MIN(), COUNT(). In this article, we will explain how the GROUP BY clause works when NULL values are involved. We will also explain about using NULLs with the ORDER BY clause. The best way to master GROUP BY and NULL in SQL is through practice. I recommend the SQL Practice track at LearnSQL.

Understanding the Use of NULL in SQL Three-Valued Logic

NULLs are necessary in relational databases, and learning to use them is fundamental to SQL success. However, NULLs should also be handled with care, as we explain in this post. In relational databases, we don’t always have a value to put in a column. For example, suppose we have a table called “persons” that has “first_name”, “last_name”, “birth_date” and “marriage_date” columns. What value will we store in the “marriage_date” column for single persons?

How to Tackle SQL NULLs: COALESCE function

It's inevitable that some data in the database has no value what in SQL is represented by the NULL keyword. "No value" here is different from zero, false, or an empty string (but with exceptions! In Oracle database, NULL is the same as string of zero length). During playing with the database, treating NULLs are becoming more and more troublesome, therefore MySQL standard provides help with some of the functions, like COALESCE.

Tag: Numerical Data Types

Understanding Numerical Data Types in SQL

Working with databases of any kind means working with data. This data can take a couple of predefined formats. As you start on your learning path with LearnSQL.com, you will start to understand SQL's different data types. In this article, we will cover different variations of the SQL numeric data type. We'll also examine some functions that convert data from one type to another. Creating tables is the first step in any SQL coding project.

Tag: Numerical Functions

SQL Numeric Functions

Review all the SQL numeric functions, including their definitions and examples. SQL’s numeric functions perform operations on numbers. They take one or more numbers as arguments and return a number as output. Note that numbers may be of different data types, including integers, doubles, and floats. You can learn more about numeric and decimal data types here. SQL numeric functions can be divided into scalar and aggregate functions. Scalar functions compute a result for each input row individually.

18 Useful Important SQL Functions to Learn ASAP

Updated on: October 30th, 2023 Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike.

Tag: Online Course

In-Person vs Online SQL Training for Data Analytics

If you want to become a data analyst, you’ll have to choose between in-person and online SQL training. Learn the pros and cons of each path in this article. Want to become a data analyst? First, you have to decide which learning method to choose – traditional, in-person classes or online courses. Technology has given us more options, leading to questions about the best fit for different learning styles and goals.

Free SQL Courses to Elevate Your Skills

In this article, I'll explain why LearnSQL.com offers free SQL courses. I’ll also introduce you to some of the courses we’ve offered for free over the years. If you're eager to enhance your SQL skills without breaking the bank, you've come to the right place. You're here because you understand the significance of learning SQL. But are you tired of those lengthy YouTube tutorials? How about diving into an online SQL course?

5 Best Online SQL Courses for Business Analysts

Why bother to learn via an online SQL course? SQL is pure profit – it allows analysts to interpret data efficiently and companies to adopt better strategies. In this post, we’ll look at our top 5 SQL courses for business analysts. Being into finance, economics, and IT systems has brought you to business analysis. It’s a fascinating combination of skills; you’re combining business and technology, which makes you a valuable asset to your company.

Five Essential Features of a Good SQL Course

There are many different platforms offering SQL courses. If you’re a beginner, it may be difficult to choose the right one for you. Find out what we think are the essential features of a good SQL course. Remember, if you make a poor choice at the beginning, you may get discouraged or get into bad habits that will impact your work down the line. What Is SQL? SQL, or Structured Query Language, is a programming language you use to talk to databases.

Top 5 Beginner Online SQL Courses in 2020

Looking for an exciting new career? Data analysis won’t disappoint you! The simplest way to make this possible is by learning SQL, and online SQL courses are the most effective learning method. Don’t know where to start? Here’s an overview of the best online SQL courses for complete beginners. There are infinite reasons for changing your industry. You may want to land a new job because you’re burnt out. You may be bored and want something more challenging.

How to Group Data by Week in SQL Server

This is additional content for the LearnSQL.com course Customer Behavior Analysis in SQL Server. In this course, we showed you how you can analyze the customer lifecycle (customer acquisition, conversion, activity, retention, and churn) with SQL. We discussed customer registration cohorts, or groups of customers who registered during the same period (e.g. same week, same month). Analyzing customer registration cohorts lets you see registration trends and relate registration cohorts with marketing campaigns.

Best Online SQL Courses for Finance & Economics Majors

Are you studying finance and wondering how you can use your knowledge in this technical world? Maybe you’ve just started working as a data analyst and you want to bring new tools and skills to your workplace? This article could help you with the list of the SQL courses worth trying. Maybe you’re studying finance and find your studies too theoretical. How will you put this knowledge into practice?

Tag: Online Practice

MySQL Practice: Best Exercises for Beginners

These 15 MySQL exercises are especially designed for beginners. They cover essential topics like selecting data from one table, ordering and grouping data, and joining data from multiple tables This article showcases beginner-level MySQL practice exercises, including solutions and comprehensive explanations. If you need to practice … Selecting data from one table Ordering and grouping data Joining data from multiple tables … these 15 tasks are just for you!

This Advanced SQL Course Will Boost Your Career!

Can you already create pretty good SQL reports? Do you want to take it a step further? In this article, I'll explain how an advanced SQL course can propel you (and your career) to the next level. Since you are looking for information about SQL, you probably already know how important data is nowadays. Very few companies can stay on the market without using the power of data or basing their strategic decisions on it.

The Best SQL Practice Challenges for Beginners

Want to get better at SQL? Dive into SQL practice challenges! They're a great way to learn and improve. In this article, we'll explore why these challenges are important and where you can find the best ones. Are you a student, a business owner, or an employee? If data is part of your work and you want to learn SQL to manage it, you’ll need to practice. And interactive SQL challenges are ideal for beginners to get comfortable with the language.

SQL Practice for Students: 11 Exercises with Solutions

Calling all students! Are you SQL-curious? Want to learn or improve your SQL skills? This article has 11 SQL practice exercises with detailed solutions. Have you ever heard that “Practice makes perfect”? You probably have – that’s why you’re looking for SQL practice resources. If you want to develop strong skills or become an expert in a certain domain, you have to practice. As Rebecca McKeown wrote in her outstanding article Learning SQL?

Learn SQL in 10 Minutes

Updated on: October 30th, 2023 Want to learn SQL fast? Our simple guide will teach you the essentials in just 10 minutes! Start querying data in no time. In today’s world, we use data for everything, and knowing SQL helps you understand this data better. Learning SQL means you can find and use important information in databases. Knowing SQL is an essential skill in any data-driven industry. For beginners, learning SQL is made easy with the right guide.

10 Beginner SQL Practice Exercises With Solutions

Solve these ten SQL practice problems and test where you stand with your SQL knowledge! This article is all about SQL practice. It’s the best way to learn SQL. We show you ten SQL practice exercises where you need to apply essential SQL concepts. If you’re an SQL rookie, no need to worry – these examples are for beginners. Use them as a practice or a way to learn new SQL concepts.

Best PostgreSQL Courses for Beginners

So you want to learn PostgreSQL but aren't sure how to get started? In this article, we look at some of the best online courses available on the Internet for learning PostgreSQL, so you can get started right away! What Is PostgreSQL? PostgreSQL is used in major companies such as Apple and Instagram. You may be wondering: should I learn PostgreSQL? PostgreSQL is a popular dialect of SQL, or Structured Query Language, a programming language for accessing and managing data in relational databases.

How to Learn SQL in a Week

Updated on: April 15, 2024 Need to learn SQL in a hurry? In this article, we’ll give you a learning path that will help you learn SQL in a week! So you want to learn SQL but don't know where to begin, how long it will take, or even if you have the time. In this article, we'll show you how you can learn SQL within a week using some resources that will get your SQL journey started in no time!

How to Practice Advanced SQL Online with LearnSQL.com

Want to go from intermediate to advanced SQL user? You’ll need to practice! Here are some ways you can practice advanced SQL online. You’ve seen how SQL helps you make data-driven decisions. Perhaps you’ve even learned some advanced features. But you’d like to become an expert—and for that, you need practice, practice, and more practice. Is it possible to get advanced SQL practice online? Taking SQL to the Next Level What is advanced SQL?

Best MySQL Courses for Beginners

SQL is among the most important languages when it comes to dealing with huge amounts of data. If your job includes analyzing or collecting data and you feel that an Excel file is not enough, you need to learn or develop your SQL skills. And if you learn SQL, you also need to know one of its most popular dialects - MySQL. If you've made the decision to learn SQL, you've come to the right place.

Learning SQL in Your Native Language is Finally Possible

Updated on: April 21, 2024 Do you or someone you know speak English as a second language? Would you like to learn SQL online in your preferred language? Good news! Our awesome SQL courses are now available in French, Spanish, German, Italian, and Portuguese! SQL, or Structured Query Language, is a programming language used for managing and manipulating data in databases. It's an essential skill for anyone working with data, whether you're a data analyst, a software developer, or just someone who wants to understand how databases work.

The Best Apps to Learn SQL

Updated on: April 23, 2024 Let us guide you to the best apps for learning SQL on the go. They are designed to seamlessly integrate into your busy lifestyle – ensuring you develop your database skills anytime, anywhere. Are you eager to dive into SQL but unsure where to start? This article is your ultimate guide to the top apps for learning SQL. We include suggestions tailored for users of all levels, from beginners to advanced learners.

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.

Top SQL Certificates in 2023

SQL is an essential skill in today’s data-driven world. Looking for the best SQL certificates to further your career can be confusing. This article gives some pointers that will help you make the best choice to fit your goals. Who needs an SQL certificate? If you can write advanced SQL queries, surely you can just demonstrate your skills at the interview and you'll be hired. Yes ... but ... you won't reach the interview unless the recruiter invites you.

Is SQL Hard to Learn?

If you have no IT skills, how hard is it to learn SQL? Will it be too technical for you? Is it worth the effort? And where would you start? In this  article I will answer those questions. As an IT consultant and trainer, I've often advised people to learn SQL. And, almost as often the reply has been, "Is it hard to learn SQL? Do I need technical or IT skills to learn it?

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).

The Future of SQL

Is it worthwhile to learn SQL? Or will a language that’s over 40 years old soon be outdated? Have relational databases been eclipsed by the advent of other database solutions like NoSQL? In this article, we answer these questions. Do you need to upgrade your IT skills? What should you learn first? The choice is daunting. If you're looking to the future, you obviously want to invest your time in something that's still widely used and will continue to be in the years to come.

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.

Top 6 Online SQL Courses for Beginners in 2024

Updated on: November 20th, 2023 Whether you’re dreaming of a career in data analytics or just want to learn a new skill, learning SQL is worthwhile. But don’t waste your time on poorly-designed courses or other learning resources! In this article, I’ve collected the best online SQL courses for beginners. Pick one and start being awesome! SQL (Structured Query Language) has emerged as one of the top skills that recruiters look for when it comes to data related jobs.

What Are the Basic SQL Queries?

You can access the data in a database using some basic SQL queries. In this article, we review the fundamentals SQL queries every beginner should know. Databases are everywhere, and they contain different kinds of data. Almost all of them support SQL, a language that lets you read and manipulate the data inside a database. In this article, I’ll show you the basic SQL queries that you can use to perform many common everyday data tasks.

Learn SQL for Data Science With LearnSQL.com

If you are interested in a data science career and have looked at a few relevant job descriptions, you've probably noticed many leading tech companies expect their data scientists to know SQL. Let's see how you can learn SQL for data science and become more valuable to any data-driven organization. A data scientist is a complex technical role that expects a combination of the skills of a statistician, a business analyst, and an IT expert.

What Is an SQL Query?

An SQL query is the most basic SQL command. It is a question you ask a database. In this article, we dive into the basics of SQL queries to kickstart your SQL journey with practical knowledge right away! SQL, or Structured Query Language, is a programming language designed to interact with databases. When you want to access data in a database, be it to alter, delete, add, or simply extract information, you use SQL.

How to Set Up a Corporate SQL Training Program

Are you looking to set up a business or corporate SQL training for your company's employees? In this article, we’ll discuss how to build an efficient SQL training program and why the LearnSQL.com platform is the choice of leading tech companies. If you are responsible for employees’ professional development – especially in a data-driven company – you know that SQL is essential for anyone who works with data. This programming language can enhance the performance of data and business analysts (for whom SQL is often a primary tool) as well as marketers, salespeople, HR specialists, auditors, and many more.

5 Tips for Learning SQL for Beginners

Being data-driven is a hot trend right now. Employers are looking for people who can work with databases. This is why you should learn SQL. In this article, I'll explain how to go about doing so. Yes, learning SQL may be the right thing for you even if you have never seen a line of code. As with any new skill, it requires the right approach and the right resources.

Learn SQL in 4 Steps

Want to work with data? You’ll need SQL. Fortunately, you can learn SQL in just 4 steps! If you are interested in data crunching or working with data in general, you’ve probably heard something about SQL. Now that data storage is cheap and accessible, data from every transaction can be stored and analyzed. Hence, there’s great demand for people who can capture and work with this data. We’ve even seen entire companies profit from being proficient with data; for example, consider the ever-growing value of Google and Facebook (now Meta).

Over 40 and Want to Upskill? Learn SQL!

You have several years of experience. Your work has even been written up in a few case studies. Yet, you still have a hard time finding the right path to improve your career. If that's true for you, the answer is to learn SQL. In this article, I'll tell you why. Why learn SQL when you’re already an experienced professional? It’s always good to learn something new. You may want to pick up a new hobby, try out a different industry, or get a new skill to help your career.

The SQL Syntax Is Simple: True or False?

Updated on: April 19, 2024 Are you contemplating learning SQL but are concerned about how difficult it may be, especially if you have no prior coding experience? If so, you are not alone. In this article, I show you how simple the syntax of SQL is and that it is worth your time to learn it. You just need to know how to approach it properly. Many people carry the notion that learning SQL is much like learning other programming languages.

These Are the Websites You Should Know When Learning SQL

Updated on: April 6, 2024 If you're diving into SQL and searching for top-notch resources to enhance your learning, you've arrived at the right article. Discover the ultimate SQL learning websites that we’ve carefully chosen to support your educational journey. Today, I'm going to share a list of websites that will help you with learning SQL. You will find useful resources, get introduced to some fantastic communities, and expand your database knowledge.

New MySQL Courses Are Here!

A lot of you have been waiting for new MySQL courses on LearnSQL.com – and finally, they’re here! Now you can learn everything MySQL in a simple, understandable, and fun way. We've worked a lot with these online SQL courses and created hundreds of interactive exercises to help you learn this popular SQL dialect. If you want to communicate with the world’s most popular open-source database, our MySQL courses will help you achieve that goal!

LearnSQL.com’s Monthly SQL Practice in 2022

Are you looking for ways to practice SQL? Tired of boring exercises based on unreal scenarios? We have something for you! Every month, we publish a new set of SQL practice exercises. You'll find all of them in the monthly SQL Practice. Here at LearnSQL.com, we believe the best way to learn SQL is through practice. All of our SQL courses (and there are over 30 of them!) are hands-on.

The Top 5 SQL Courses and Learning Platforms for 2022

It’s the New Year! Time to start thinking what good you can do yourself in 2022. If you haven’t decided yet, we want to recommend learning something new – specifically, learning SQL. Maybe learning SQL is already on your 2022 to-do list. If so, take it seriously – learning SQL can change your career path and even your life! It makes sense to find the best SQL courses so you can learn effectively.

Top 10 Beginner Online SQL Courses in 2022

Ready for New Year’s changes? Good, because now you have a perfect chance to achieve something new: Improve your skills by learning SQL! In this article, we’ll point you toward some great online SQL courses to help you meet this goal. SQL, or Structured Query Language, is the language used to communicate with relational databases. When you know SQL, you can add, delete, change, and make calculations using the data in a database.

Top 5 MS SQL Server Courses for Beginners

Every journey, including a career change, begins with the first step. If you're thinking about learning data analysis or strengthening your MS SQL Server skills arsenal, you've come to the right place. Here are the top 5 MS SQL Server online courses. Enjoy! You've probably heard that today’s organizations rely heavily on data analysis. You heard right. They are looking for employees who can navigate the world of databases and draw conclusions from data.

New Window Functions Practice Set Is Here!

Have you learned the SQL window functions? Or maybe, you forgot when and how to use them correctly? Are you preparing for an advanced SQL job interview? You've come to the right place! This is the new Window Functions Practice Set. This is very good news for all SQL learners and database professionals who want to improve their skills. The LearnSQL.com Team is proud to present the new Window Functions Practice Set!

How Hard Is It to Learn SQL Without IT Experience?

Updated on: September 12, 2023 Learning SQL doesn't have to be difficult! Taking an interactive SQL course is a great way to start your career in the high-paying world of IT. When you started your adventure with computers, you surely didn't realize how far you could go. You were probably only a few years old, and your first experience with a computer was probably gaming. Today, computers provide more than just quick access to entertainment; they’re a great tool for earning money.

Why Is the SQL Practice Set my Favorite Online Course?

My friends know that I cannot sit still. I always have to do something, read something, and learn new stuff. It's stronger than me. But I don't complain, because this approach has only helped me in my life. I have done a ton of different online courses, but the SQL Practice Set has proved to be the best so far. Find out why. Learning SQL was not easy for me.

I Needed a Good SQL Course… So I Chose SQL Basics.

Why did I decide to take a SQL course? And how did I come across LearnSQL.com? It’s story time! Did I ever think that my professional career would deal with databases? Absolutely not. It didn’t even cross my mind that it would happen. Let me explain why I started learning SQL … and how I got to where I am today. Meet the SQL Newbie I suppose few people have their lives planned from A to Z.

How to Learn SQL Faster

Struggling with learning SQL? Does it seem like you’re doing everything right, but not making progress as fast as you’d like? Don't worry, I'll help you. Here are some tips for learning SQL quickly and painlessly. Are you wondering how to learn SQL faster? If so, I’m here to help with some practical tips. And once you’ve found the right motivation and the right sources of knowledge, you’ll be able to learn faster.

New Basic SQL Practice Course on LearnSQL.com

Hey, did you hear that there’s a brand-new Basic SQL Practice course on LearnSQL.com? This is a great opportunity to refresh your SQL, write some queries, and take your analytical skills to the next level. We’re proud to introduce Basic SQL Practice: A Store! Where did the idea for this new SQL practice course come from? From our users! They’ve let us know that they need more hands-on SQL exercises at a beginner level.

I Took the SQL Basics Course... Here's What Happened!

In this article, I will share my personal story with you. But don't worry – it's not about a scandal or a sad story of failure. I'll tell you how a successful news journalist fell in love with SQL. It all started when I took the SQL Basics course at LearnSQL.com. There are moments in life that change everything. Mine happened when I decided to give up my long-term career and start a completely new chapter in my professional life.

Free Online Courses You Should Take If You Use SQL

If you are an SQL enthusiast, already work with SQL, or want to learn it – you'll surely be interested in acquiring new skills that will support your growth. These free courses will increase your productivity, help you find your way around the work environment, and help you become a better analyst. By the way, they are also fun. Whoever said learning new things is easy has never tried to learn quantum physics (thank you, Mr.

Best Online SQL Courses for 2021

In this pandemic era, it's no surprise that online learning has become even more popular. To help you narrow things down, I’ve prepared a list of 2021’s 10 best online SQL courses. Find out where you can learn SQL effectively! The number of online courses on offer – especially in the tech industry – is now impressive. You can find something that suits your interests, competences, and professional ambitions. But how do you know which to choose among the many online SQL courses out there?

Does Music Improve Work Efficiency?

Updated on: April 15, 2024 Do you sometimes have trouble focusing when working or studying SQL? Do you ever lack motivation? I have the perfect solution for you: music for learning SQL! I am excited to tell you about how the right tunes can significantly enhance your efficiency and concentration. Music can soothe the savage beast, they say. It can also inspire action. In general, music is an important element of human life.

Who Should Learn SQL?

If you learn SQL, will you use it in your current (or dream) job? If you learn it, will it help you with your daily tasks? SQL has so much potential that everyone can benefit from it – including you! Read this article to find out how much you will gain by knowing SQL. I could answer the title question with one word: everyone! But not everyone wants to learn SQL.

What Is the RANK() Function in SQL, and How Do You Use It?

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.

What Is CASE in SQL?

SQL CASE is a very useful expression that provides if-else logic to your SQL queries. It’s a slightly more advanced topic, but you’ll need it when preparing reports – it will deliver massive value to your personal and professional projects. The SQL CASE statement is a control flow tool that allows you to add if-else logic to a query. Generally speaking, you can use the CASE statement anywhere that allows a valid expression – e.

Is MS SQL Server Still Worth Learning in 2024?

Updated on: March 10, 2024 MS SQL Server is an in-demand skill in today’s job market. Should you learn  MS SQL Server in 2024? In this article, I’ll answer this question. Thinking about whether you should dive into Microsoft SQL Server in 2024 – especially with so many free database alternatives available? MS SQL Server has been a go-to for handling data for ages, thanks to its solid features and reliability.

Best SQL IDEs for You

Maybe you just started learning SQL. Maybe you already have some experience. Whatever your situation is, choosing the right IDE for you is another step in your development. Why IDE? IDE stands for integrated development environment. It is a software application that enables us to combine various aspects of writing a computer program. An IDE usually contains a source code editor, build automation tools, and a debugger. You might ask why you need an IDE when you have the command line available on your computer.

Where Can I Find Good Courses to Practice MS SQL Server?

Updated on: April 6, 2024 Begin your journey to mastering MS SQL Server with the finest practice exercises out there. Whether you are a beginner or seeking to improve your T-SQL skills, explore the top destinations for the most engaging and interactive MS SQL practice courses online. You've started learning MS SQL Server. Maybe you've done a course, watched some YouTube tutorials, and feel pretty confident in your knowledge. What now?

How Much SQL Practice Do You Need to Become a Pro?

Are you wondering how long it will take to learn and practice SQL before you can call yourself a pro? In this article, I will try to help you answer this question. Being a pro in SQL can mean many different things. Some people would say that being a professional is about mastery of advanced SQL, i.e. window functions or complex subqueries. For other people, being a professional means getting paid for your skills.

Learn SQL And Start Your Journey Towards Personal Growth

Are you at the very beginning of your career and don't know what employers are looking for? Maybe you already have a lot of experience, but feel like it's time to change or update your skillset. Learning SQL can be a great choice. Read on and find out why. Regardless of your career stage, you cannot neglect your personal development. Whoever does not move forward falls behind. As you start learning new things, new opportunities will open up for you, both in your personal and professional life.

6 Advanced SQL Queries for Analyzing Financial Data

Are you an advanced SQL user who’s new to finance? Do you want to learn how to use your knowledge to analyze financial data? The article will give you some guidance. You probably know that SQL is a potent tool for analyzing all sorts of data. The bigger and more complex data, the more beneficial SQL becomes. In certain situations, financial data can be very complicated; producing a sophisticated analysis requires sophisticated tools.

How Much SQL Do I Need to Know?

Learning a new skill or starting a new profession can be a real challenge, especially when you’re unsure of how much you really need to know before taking the plunge. Imposter syndrome is also a real thing – how could you possibly catch up with all those SQL ‘experts’ who seem like they’ve been doing this since they were in diapers? The good news is you can learn SQL quickly and easily, and you don’t need to know nearly as much as you think you do.

Data Types in SQL

Read this article and learn the ABC of SQL data types. Data types are used to define the type of data stored in a database. However, there are related concepts that a good SQL developer should know: data type conversion, what operations are possible between different data types, date arithmetic, etc. SQL also provides functions that manipulate values of different data types (i.e. functions for string data, date and time data, etc.

Where Can I Find Good SQL CTE Exercises?

Find the top online resources for SQL Common Table Expression (CTE) exercises! CTEs allow you to structure and organize SQL queries efficiently, which is essential if you want to advance your SQL knowledge. A Common Table Expression, or CTE, is a SQL syntax that creates a temporary data set. This set contains separate data than the main query, which can typically be referenced or reused in a subsequent query. A CTE is considered temporary because the result is not permanently stored anywhere and only exists for the duration of the query.

Stories of the LearnSQL Scholarship Program

2020 is behind us. It was an extremely difficult year: We’ve struggled with the Covid-19 pandemic, a worldwide economic crisis, and constant anxiety. Many people have lost their jobs and their prospects for a better tomorrow. That's why we decided to do something positive: establishing a SQL scholarship program. We decided to find people in difficult situations and try to help them. For many, learning SQL can be their chance to get a job and develop their career.

Best SQL Video Tutorials for 2021

Ready for this year’s picks for the best YouTube SQL video tutorials? Here are our top 5 choices! It's been well over a year since I last wrote about SQL tutorials on YouTube. Those seven channels can help you learn the basics of SQL quite painlessly, but now it's time to add to that list with 2021’s top contenders. Which YouTube SQL tutorials are worth your time and attention? I’ve got my favorites, but first, let’s consider an important question:

Why Learn SQL This New Year?

In answering this question, we’ll take a look at the idea behind New Year’s resolutions, explore what SQL is, and see why learning it should be your goal for 2021. We’ve all heard of New Year’s resolutions, and we all have personal experience of how difficult it can be to see them through to a successful conclusion. We’ll examine the history of New Year’s resolutions, why they often fail, and how to ensure your resolution for learning SQL in 2021 doesn’t meet with the same fate as so many others that never made it past the end of January.

2020’s Best LearnSQL.com Articles

We published a whole lot of interesting SQL articles this year. I had a difficult task – choosing the best LearnSQL.com articles of 2020. And here they are. The crazy year of 2020 is coming to an end. How will we remember it? Probably by the COVID-19 pandemic; we stayed home and fought the virus. It was a difficult time. However, many of us did not give up and kept trying to achieve our professional goals.

The Best SQL Lectures on YouTube

YouTube contains a vast amount of information. The trick is to know how to find what’s valuable. If you type “SQL lectures” in the YouTube search engine, you will probably get a list of boring or unhelpful clips. However, there are hidden gems, and I’ve compiled a list of the best SQL talks I’ve found on YouTube so far. First, let's establish one thing. I didn't choose any YouTube SQL tutorials when making this list.

Practicing SQL for Your First Day of Work

Your new SQL job is likely to surprise you in many ways. To minimize the risk of getting lost in the jungle of data, I recommend you get some additional SQL practice before your first day. There are special SQL practice sets and projects on the internet to help you prepare. You’ll also get help from your colleagues, as programmers are usually open and supportive. If you’re reading this, you’ve probably heard about the opportunities SQL and data science offer.

How Do You Write a SELECT Statement in SQL?

SQL is a language to communicate with relational databases, and the SELECT statement is the first thing you’ll learn when you start using SQL. In this article, you’ll learn how to write SELECT statements, from the basics to more advanced. What Is SQL? SQL stands for “Structured Query Language.” It has a long history that started in the 1970s. Being the standard for communication with relational databases, it has maintained its popularity.

How To Learn The SELECT Statement in SQL

When you think about learning SQL, one of the first things you come across is the SELECT statement. Selecting information is arguably the most important SQL feature. In this article, we’ll demonstrate the typical use cases for SQL SELECT with practical examples. Read this article if you’re a beginner database user and would like to know what SELECT can do for you. SQL, or Structured Query Language, is the programming language the IT world uses to communicate with databases.

Practice SQL Before Interviewing a Potential Employee

Has your company grown to the point that you need to hire an SQL expert? Have you found a candidate for the job? How do you prepare for the interview, especially if you don’t know SQL? Don't worry! Follow our suggestions on how to practice SQL. We have tips and tricks to help you feel confident and find the perfect employee. Who You Want To Hire First of all, you need to know the requirements for the new employee.

Top 7 Online Courses for Data Engineers

This article summarizes the top online courses available for data engineers. We have picks suitable for beginners as well as intermediate learners. If you’re interested in database design and management, check these courses out! Most individuals who aspire to enter the realm of data aim for data scientist or data analyst roles. While these roles are indeed very rewarding because of their tangible links to customers and business direction, the role of data engineers is equally vital for businesses that operate in a data-rich environment.

Where to Go After Learning SQL Basics

Learning to code is – in general – a lot of fun, for sure. Even after a few years in the IT industry, I still love learning new technologies. And I now know that learning with a good plan is even better than learning without one. This also applies to learning with advanced SQL courses. In this article, I'll show you how learning paths can save you some time and a lot of frustration.

Kickstart SQL Learning with Our SQL Basics Course

Updated on: February 19, 2024 Why learn SQL from our interactive online courses? Two reasons: 1) Power up your career. 2) Avoid being a noob. What does it mean to be a noob? “Noob” comes to us from the world of computer games. It’s a combination of “newbie” and “beginner”. It’s not a very nice word. It means that someone has found you an inexperienced player and (even worse) resistant to learning.

Is Learning SQL for Free Worthwhile?

Everyone likes to get something for free, even when it comes to SQL courses. But is free always good? Find out how and where you can learn SQL for free – in a way that’s worth your time. Beginner-friendly database courses and SQL tutorials often promise to teach SQL fundamentals like SELECT, WHERE, GROUP BY, HAVING, and ORDER BY. These commands are the basis of a powerful set of skills for entry-level jobs in data analysis or databases.

New Course: Customer Behavior Analysis in SQL

Good news! A new SQL course is here! We’re happy to announce the release of our Customer Behavior Analysis in SQL course. Do you want to get to know your clients and better understand their needs and behavior? If so, this great interactive SQL course is for you. Discover the power of full customer lifecycle analytics in SQL and know more than your competitors. The LearnSQL.com team is happy to announce the release of a new SQL course on our platform: Customer Behavior Analysis in SQL.

Did You Know LearnSQL.com Has Free SQL Courses?

Who doesn't like getting something for free? Each month, we give LearnSQL.com users a bit of help in their learning journey – a free, fully interactive SQL course. Since April, we have been giving our users the opportunity to learn SQL for free. Each month, we choose one of our SQL courses and give you full access to it for that month – completely free of charge! Cool, right?

SQL Course of the Month – Analyzing Revenue Trends in SQL

We work hard, we learn SQL, and we develop professionally. But why? For our own satisfaction, but also for money! The knowledge of SQL will increase your income significantly. If you are proficient in SQL, you can better analyze your company's revenue. How? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo. In this article, she answers your questions about our September SQL Course of the Month: Analyzing Revenue Trends in SQL.

Where Can I Find Free Online Data Sets to Practice SQL?

Updated on 4th Sep 2023. Diving into the world of SQL can be an exciting journey. But to truly master this language, you need to practice SQL regularly. In this article, we'll guide you through some free online data sets that will help you take your SQL practice to the next level. Let's get started! You've successfully installed your chosen RDBMS and grasped the basics of SQL. So, what's the next step?

5 Reasons You Might Fail to Learn SQL

Learning SQL isn’t hard, but that doesn’t mean you’ll sail through, problem-free. Here are five things that might cause unwary SQL learners to fail. For me, learning SQL wasn’t always about the joy of discovery. Learning itself is not all about curiosity and the satisfaction of succeeding. Sometimes there is a sense of failure. We’re often told it is better to focus on positives. I believe this. However, it is also crucial to find out what went wrong when we don’t succeed at something.

Learning SQL When You Work and Have a Family

Do you want to learn SQL but feel you can’t squeeze one more thing into your jam-packed life? Here are my tips on learning SQL when you work and have kids. You work full-time and have a family. Daily responsibilities overwhelm you. I’ve been there. Heck, I live there. I work from home and have a family. While I was writing this article, I was also waiting for a call on Zoom, doing the laundry, and cooking some pasta for my son’s dinner.

SQL Course of the Month – Recursive Queries

Recursive Queries is one of SQL’s more advanced features. You could say they divide SQL users into beginners and experts. But how do you learn recursive queries? And why do you need them, anyway? Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, is here to help. In this article, she answers your questions about our August SQL Course of the Month: Recursive Queries. Recursive queries … that sounds very serious.

SQL Course of the Month – PostGIS

It's summer, and it's travel time ... at least it would be under normal conditions. The pandemic is still going on, but that doesn't stop us from dreaming about distant trips and visits to beautiful places. For now, most of us will have to do it on a map. Did you know that databases can store geographical data? With interactive maps, if you find a nice summer house on the internet, you can accurately track it and plan the best route there.

How to Learn the SQL Syntax

Read about what SQL is, and choose the best way for you among a wide variety of possibilities for learning SQL and remembering its syntax. What Is SQL? “SQL” stands for “Structured Query Language,” and as it sounds, it is a language dedicated to querying a relational database. In practice, it is used for creating, designing, and managing a relational database. People use SQL to: Create sets of tables and rows Modify database tables and index structures Insert, update, and delete data Retrieve information from a database for a variety of uses such as analytics Relational databases consist of a set of tables containing rows and columns of data.

Last-Minute Preparation Tips for a Database Class Exam

Getting to learn SQL is fun. You don’t really need to spend much time to understand some basic SQL concepts and use them fluently. If you’re a student facing your first database class exam soon, we’ve got you covered. In this article, we explain what you should focus on while learning SQL and studying for an entry-level database exam. Check your knowledge with our 10 sample questions and discover where you can find more SQL practice.

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.

Advanced SQL Courses for Data Analysts – A Complete Review

Even data analysts who already know SQL need to keep their skills sharp. Where can you find the best advanced SQL courses for data analysts? Check out our review of the top online sources! In this article, I present a list of online SQL courses for data analysts. These courses are offered by various platforms. Why wait? Let’s jump right in! 8 Advanced SQL Courses for Data Analysts Let's take a closer look at these courses to decide which platform will be better for you in learning SQL.

Top 3 Platforms to Learn SQL Online: A Complete Comparison

Do you want to learn SQL online? Where do you start? There are many choices on the internet, and it can be hard to decide. But don’t worry—I tested and compared three major platforms to help you find the best place to learn SQL online! E-learning is on the rise. It gives us infinite possibilities of growing our professional careers without leaving our homes. And increasing our competencies is especially important now that the labor market has become dynamic and unstable.

Why Take the “SQL Basics” Course at LearnSQL.com

LearnSQL.com’s interactive “SQL Basics” course teaches the foundations of SQL. Discover why we built this online course, our philosophy behind it, and what it contains! What Is SQL, and Why Should You Learn It? SQL is a language used to talk to databases, computer programs that hold data and can process it efficiently. SQL can select data from a database and perform various computations on the data, be they simple or complex.

What is the Best SQL Training Online?

Updated on: April 16, 2024 Mastering SQL training is crucial, but let's face it—you won’t become an expert in just a couple of weeks. With countless resources available, it can be quite a challenge to even know where to begin your SQL journey. How do you effectively practice and hone these essential skills? Savvy and knowledgeable database professionals have consistently been in high demand over the last five years. If you are aiming to advance your career as a database developer, administrator, warehousing specialist, or analyst, SQL training and mastery is an absolute necessity.

The 50 Best Resources for Learning SQL (Updated for 2024)

Updated on: December 6, 2023 Do you want to know where to learn SQL? We’ve got you covered with the ultimate list of 50 SQL learning resources, including the best SQL courses, tutorials, books, and much, much more! Learning SQL can be hard enough without wading through thousands of websites and articles. So, we thought we’d do you a solid and put the top SQL resources here in this handy slice of the internet.

How to Practice SQL After a Video Course

Updated on: April 19, 2024 When you're just starting to learn coding, the most obvious first step is to watch online video courses. They're one of the most popular ways to learn the basics of a new technology without investing a lot of time and money. But you need to do more than that to master the topic. What should be your next step? When someone asks me about how to start learning to code, I often recommend trying video tutorials first.

How to Rank Rows in SQL: A Complete Guide

Don’t struggle with SQL ranking functions anymore! This article will guide you through the most common ranking use cases. Rankings are used around us every day. Sports tournaments, the best movies and TV series on Netflix, stores with the cheapest products—these are only a few examples of rankings you might’ve seen recently. Using SQL RANK functions might be hard sometimes. The variety of different constructions is enormous. You can easily get lost in everything there is to learn about ranking.

How to Practice SQL JOINs

Updated on: November 7, 2023 There is no better way to learn how to practice SQL joins than through hands-on experience. However, there will probably be obstacles along the way. I’ll cover some of these obstacles and give ideas for how to overcome them. While this article won’t turn you into SQL JOINs expert, it will show you how to become one. So, let’s start! Diving into the world of databases?

Stay at Home and Learn SQL for Free with LearnSQL.com

Working remotely is a dream come true for some. You ditch commuting and have more time for the people you love and the things you enjoy. For others, it's a challenge to maintain their focus when there are new distractions. It's also an opportunity to invest the few gained hours in learning something new. Staying at home can be a time when you might find yourself busier than you've ever been, but not getting many things done, and worse, not learning what you planned to.

Video Tutorial or Interactive SQL Course – Which Is Better?

Are you ready to get started with SQL but unsure which learning method is the most effective? In this post, we’ll talk about the pros and cons of learning SQL from an instructional video vs. an interactive online course. Are you a chronic Internet-using student who’s planning to learn SQL? Maybe you did some research but still don’t know which kind of training is worth your (limited) time. We all have families, hobbies, and other after-work commitments, and finding the right resource for learning SQL will save you some time.

Learning SQL? 12 Ways to Practice SQL Online

If you’re currently learning SQL, you may have found yourself knee-deep in reading material and may be wondering how on earth you can bridge the gap between book knowledge and real-life SQL application. In this article, we bring you 12 of the most effective ways to practice SQL online, taking you from a bookworm to a database butterfly in no time at all! All theory and no practice will make you a frustrated SQL user!

Tag: Operating on Data

18 Useful Important SQL Functions to Learn ASAP

Updated on: October 30th, 2023 Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike.

Tag: Operator

What Does a Double Colon Operator in PostgreSQL Do?

The double colon operator :: in PostgreSQL is a synonym for CAST, which converts a value into a different data type.  If you are curious about the details , read on! Have you ever seen a double colon (::) operator in someone’s PostgreSQL code? It would look something like this: SELECT '2022-09-02'::date; This code converts the text '2022-09-02' to a date datatype. As mentioned above, the double colon replaces the CAST operator.

Tag: Oracle

SQL Date and Time Functions in 5 Popular SQL Dialects

Are you confused by all the date and time functions used across different SQL dialects? In this article, I summarize the date and time data types used in PostgreSQL, Oracle, SQLite, MySQL, and T-SQL. I also provide examples with the key SQL date and time functions used across these dialects. It’s time to become date and time gurus! Do you want to calculate how often employees are running late for work?

How to Order by Date in PostgreSQL or Oracle

Problem: You want to sort the rows by date in PostgreSQL or Oracle database. Example 1: The exam table has two columns, subject and exam_date. subjectexam_date Mathematics2022-12-19 English2023-01-08 Science2023-01-05 Health2023-01-05 ArtNULL You want to sort the rows by exam_date. Solution: SELECT * FROM exam ORDER BY exam_date; The result looks like this (the rows are sorted in ascending order by exam_date):

How to Find the Difference Between Two Timestamps in Oracle

Problem: You have two columns of the type timestamp and you want to calculate the difference between them. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between the arrival and the departure. The travel table looks like this: iddeparturearrival 12018-03-25 12:00:002018-04-05 07:30:00 22019-09-12 15:50:002019-10-23 10:30:30 32018-07-14 16:15:002018-07-14 20:40:30 42018-01-05 08:35:002019-01-08 14:00:00 Solution: SELECT id, departure, arrival, arrival - departure AS difference FROM travel; The result is:

How to Calculate Date Difference in PostgreSQL/Oracle

Problem: You have two columns of the date type and you want to calculate the difference between them in PostgreSQL or Oracle database. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between arrival and departure and the number of days from arrival to departure inclusively. The travel table looks like this: iddeparturearrival 12018-03-252018-04-05 22019-09-122019-09-23 32018-07-142018-07-14 42018-01-052018-01-08 Solution: SELECT id, departure, arrival, arrival - departure AS date_difference, arrival - departure + 1 AS days FROM travel; The result is:

How to Create a Table with a Foreign Key in SQL

Problem: You want to create a foreign key for a table in a database. Example: We would like to create a table named student that contains a foreign key that refers to the id column in the table city. Solution 1: Creating new table with single-column foreign key CREATE TABLE student ( id INT PRIMARY KEY, first_name VARCHAR(100) NOT NULL, last_name VARCHAR(100) NOT NULL, city_id INT FOREIGN KEY REFERENCES city(id) ); Discussion: To create a new table containing a foreign key column that references another table, use the keyword FOREIGN KEY REFERENCES at the end of the definition of that column.

How to Delete a Foreign Key Constraint in SQL

Problem: You want to delete a foreign key from a table in a database. Example: We want to remove the foreign key named fk_student_city_id from the table student. Solution: ALTER TABLE student DROP CONSTRAINT fk_student_city_id; Discussion: To delete a foreign key from a table, use the ALTER TABLE clause with the name of the table (in our example, student) followed by the clause DROP CONSTRAINT with the name of the foreign key constraint.

How to Group by Two Columns in SQL

Problem: You want to group your data by two columns so you can count some statistics. Example: In the order table, you have the columns order_date, product_id, customer_id, and number. You would like to count the number of products bought by each customer each day. The order table looks like this: order_dateproduct_idcustomer_idnumber 2023-11-25711 2023-11-251213 2023-11-265312 2023-11-26124 2023-11-26321 2023-11-261627 2023-11-26332 2023-11-27631 Solution: SELECT order_date, customer_id, SUM(number) AS products_number FROM order GROUP BY order_date, customer_id; The result is:

How to Calculate a Square Root in SQL

Problem: You want to find the square root of a number in SQ:. Example: You want to compute the square root of all numbers in the column number from the table data. number 9 2 1 0.25 0 -4 Solution: SELECT number, SQRT(number) AS square_root FROM data; The result is:

How to Group by Year in SQL

Problem: You want to group your data by year in SQL. Example 1: One of the columns in your data is transaction_date. It contains a date. You would like to group all your data by year and calculate the total money earned each year. The data table looks like this: transaction_datemoney 2018-03-251700 2019-09-12100 2018-07-141200 2018-01-05400 2019-06-082000 2020-03-061500 Solution 1: Displaying the year and the money earned SELECT EXTRACT(year FROM transaction_date) AS year, SUM(money) AS money_earned FROM data GROUP BY EXTRACT(year FROM transaction_date); The result is:

How to Make a Column Unique in SQL?

Problem: You would like to make a column unique in a given table in a database. Example: We would like to make the column name unique in the table product. The query below presents one way to do it. Solution 1: Creating new table with a UNIQUE constraint CREATE TABLE product ( id INT NOT NULL PRIMARY KEY, name VARCHAR(100) UNIQUE, producer VARCHAR(100), category VARCHAR(100) ); Discussion: In this example a given column (the column name) was made unique by adding the clause UNIQUE at the end of the column definition (name VARCHAR(100) UNIQUE).

How to remove a unique constraint in SQL?

Problem: You would like to remove a unique constraint from the column/columns in a table in a database. Example: We would like to drop the unique constraint in the table product from the column name. The statement below shows how to do it. Solution ALTER TABLE product DROP CONSTRAINT UQ_product_name In this example the table product is altered by using the ALTER TABLE clause. After this clause you enter the name of the table (in our example: product) and the clause DROP CONSTRAINT with the name of the unique constraint you want to remove.

How to Get Yesterday’s Date in Oracle

Problem: You would like to display yesterday's date (without time) in an Oracle database. Solution 1: SELECT TO_DATE(CURRENT_DATE - 1) AS yesterday_date FROM dual; Assuming today is 2020-09-24, the result is: yesterday_date 2020-09-23 Discussion: To get yesterday's date, you need to subtract one day from today. Use CURRENT_DATE to get today's date. In Oracle, you can subtract any number of days simply by subtracting that number from the current date.

How to Concatenate Strings in SQL

Problem: You want to join strings from two columns of a table into one. Example: Our database has a table named student with data in the following columns: id, first_name and last_name. idfirst_namelast_name 1LoraSmith 2EmilBrown 3AlexJackson 4MartinDavis Let’s append the first name to the last name of the student in one string. Use a space between each name.

How to Filter Records with Aggregate Function AVG

Problem: You want to filter groups of rows in by the average value of a given column. Example: Our database has a table named product with data in the following columns: id, name, store and price. idnamestoreprice 1milkGreen Shop2.34 2breadClark’s Grocery3.56 3breadSuper Market4.15 4milkSuper Market1.80 5breadGrocery Amanda2.26 6milkViolet Grocery3.45 7milkClark’s Grocery2.10 8breadViolet Grocery2.

How to Filter Records with Aggregate Function COUNT

Problem: You want to find groups of rows with a specific number of entries in a group. Example: Our database has a table named product with data in the following columns: id, name and category. idnamecategory 1sofafurniture 2glovesclothing 3T-Shirtclothing 4chairfurniture 5deskfurniture 6watchelectronics 7armchairfurniture 8skirtclothing 9radio receiverelectronics Let’s find the category of products with more than two entries.

How to Filter Records with Aggregate Function SUM

Problem: You need to filter groups of rows by the sum of a given column. Example: Our database has a table named company with data in the following columns: id, department, first_name, last_name, and salary. iddepartmentfirst_namelast_namesalary 1marketingLoraBrown2300 2financeJohnJackson3200 3marketingMichaelThomson1270 4productionTonyMiller6500 5productionSallyGreen2500 6financeOlivierBlack3450 7productionJenifferMichelin2800 8marketingJeremyLorson3600 9marketingLouisSmith4200 Let’s find the names of departments that have sums of salaries of its employees less than 7000.

How to Filter Rows without NULL in a column

Problem: You want to find records without a NULL in a column. Example: Our database has a table named product with data in three columns: id, name, and price. idnameprice 1butterNULL 2milk2.35 3bread3.25 4cheeseNULL Let’s find the names and prices of products that have a price (without a NULL). Do this by using the IS NOT NULL operator.

How to Find Records with NULL in a Column

Problem: You want to find records with NULL in a column. Example: Our database has a table named children with data in four columns: id, first_name, middle_name, and last_name. idfirst_namemiddle_namelast_name 1JohnCarlJackson 2TomNULLThomson 3LisaAliceNULL 4AnneNULLSmith Let’s find the id, first name, and last name of children without a middle name (NULL in column middle_name). We use the IS NULL operator for this. Solution: SELECT id, first_name, last_name FROM children WHERE middle_name IS NULL; Here’s the result:

How to Find Rows with Maximum Value

Problem: You want to find rows which store the largest numeric value in a given column. Example: Our database has a table named student with data in the following columns: id, first_name, last_name, and grade. You want to find the students who have the highest grades. idfirst_namelast_namegrade 1LisaJackson3 2GaryLarry5 3TomMichelin2 4MartinBarker2 5EllieBlack5 6MarySimpson4 Solution: SELECT id, first_name, last_name, grade FROM student WHERE grade = (SELECT MAX(grade) FROM student); Here’s the result:

How to Find Rows with Minimum Value

Problem: You want to find rows which store the smallest numeric value in a column. Example: Our database has a table named weather with data in the following columns: id, city, and temperature. You want to find cities with the lowest temperature. idcitytemperature 1Houston23 2Atlanta20 3Boston15 4Cleveland15 5Dallas34 6Austin28 Solution: SELECT id, city, temperature FROM weather WHERE temperature = (SELECT MIN(temperature) FROM weather); Here’s the result:

How to Convert a String to Uppercase in SQL

Problem: You would like to convert a string to uppercase in SQL. Example: Our database has a table named questionnaire with data in the following columns: id, first_name, last_name, and favorite_car. idfirst_namelast_namefavorite_car 1AlanJacksonHonda Civic 2ElisaThomsonTOYOTA Camry 3MaryMartinesNissan rogue 4ChrisBrownford focus 5AdamSpringRam PICKUP Our table stores the make and model of the favorite car for each person who filled out our questionnaire.

How to Find the Average of a Numeric Column in SQL

Problem: You’d like to calculate the average of numbers stored in a column. Example: Our database has a table named sale with data in the following columns: id, city, year, and amount. idcityyearamount 1Los Angeles20172345.50 2Chicago20181345.46 3Annandale2016900.56 4Annandale201723230.22 5Los Angeles201812456.20 6Chicago201789000.40 7Annandale201821005.77 8Chicago20162300.89 Let’s calculate the average sales, regardless of city or year.

How to Find the Maximum Value of a Numeric Column in SQL

Problem: You’d like to find the maximum value of a numeric column. Example: Our database has a table named product with data in the following columns: id, name, year, and items. idnameyearitems 1bread roll2018345 2chocolate2017123 3butter201934 4bread roll2019456 5butter201856 6butter201778 7chocolate201987 8chocolate201876 Let’s find the maximum number of items sold over all years.

How to Find the Minimum Value of a Column in SQL

Problem: You’d like to find the smallest numeric value in a column. Example: Our database has a table named employment with data in the following columns: id, first_name, last_name, department, and salary. idfirst_namelast_namedepartmentsalary 1EllieMartinesmarketing1200 2MartinJohnsonfinance2300 3MichaelJacobsproduction1100 4StephenKowalskimarketing4300 5StanleyMillermarketing3500 6JenyBrownfinance5000 7MargaretGreenmarketing1500 8LisaThomasproduction2800 Let’s find the lowest salary among all employees.

How to Number Rows in SQL

Problem: You would like to give each row in the result table a separate number. Example: Our database has a table named furniture with data in the following columns: code (primary key) and name. codename 101bed 202sofa 333chair 123bookcase 235table 766desk The furniture table stores the name of pieces of furniture that we want to number.

What’s the Difference Between RANK and DENSE_RANK in SQL?

Problem: You want to compare the rankings produced by RANK and DENSE_RANK and add them as new columns to a table. Example: Our database has a table named sales_assistant with data in the following columns: id (primary key), first_name, last_name, month, and sold products. idfirst_namelast_namemonthsold products 1LisaBlack 52300 2MaryJacobs52400 3LisaBlack 62700 4MaryJacobs62700 5AlexSmith 62900 6MaryJacobs71200 7LisaBlack 71200 8AlexSmith 71000 Let’s display each sales assistant’s first and last name and number of sold products.

How to Add Rankings with DENSE_RANK() in SQL

Problem: You want to add a ranking position to rows consecutively, even if the rows have the same values. Example: Our database has a table named competition with data in the following columns: id (primary key), first_name, last_name, and score. idfirst_namelast_namescore 11JohnThomas345 14MaryJohnson222 16LisaBrown154 23AlanBlake222 32ChrisTaylor154 Let’s display all details about students: their last name, first name, and scores sorted by score in descending order.

How to Floor Numbers in SQL

Problem: You want to round a number down to the nearest integer. Example: Our database has a table named employee with data in the following columns: id, first_name, last_name, and hours_worked (for the current month). idfirst_namelast_namehours_worked 1AlanWatson95 2LisaBlack225 3LauraWilliams104 Let’s show the first and last name of each employee along with the number of days they worked.

How to Round Numbers in SQL

Problem: You want to round a number to a specific number of decimal places in SQL. Example: Our database has a table named product with data in the following columns: id, name, and price_net. idnameprice_net 1bread2.34 2croissant1.22 3roll0.38 Suppose there’s a tax of 24% on each product, and you’d like to compute the gross price of each item (i.e., after taxes) and round the value to two decimal places.

How to Round Up a Number to the Nearest Integer in SQL

Problem: You want to round up a number to the nearest integer in SQL. Example: Our database has a table named rent with data in the following columns: id, city, area, and bikes_for_rent. idcityareabikes_for_rent 1Los Angeles1302.151000 2Phoenix1340.69500 3Fargo126.44101 Let’s show each city’s name along with the ratio of its area to the number of bikes for rent.

How to Use LIKE in SQL

Problem: You need to search for specific patterns (certain combinations of letters or numbers) within text data in your database. We'll show you how to use the LIKE operator in SQL to: Find city names starting with S Find city names with exactly five characters Find city names starting with S and with o as the second-to-last character You'll also learn how to use LIKE and wildcard operators in SQL to find your own patterns in text data in your database.

How to Count the Number of Rows in a Table in SQL

Problem: You’d like to determine how many rows a table has. Example: Our database has a table named pet with data in the following columns: id, eID (electronic identifier), and name. ideIDname 123456sparky 223457mily 3NULLlessy 4NULLcarl 534545maggy Let’s count all rows in the table. Solution: COUNT(*) counts the total number of rows in the table:

How to Replace Part of a String in SQL

Problem: You’d like to replace part of a string with another string. Example: Our database has a table named investor with data in the following columns: id, company, and phone. idcompanyphone 1Big Market123–300-400 3The Sunny Restaurant123–222-456 4My Bank123-345-400 We’d like to change the phone number format for each company by replacing the hyphen character with a space.

How to Sum Values of a Column in SQL?

Problem: You’d like to sum the values of a column. Example: Our database has a table named game with data in the following columns: id, player, and score. idplayerscore 1John134 2Tom 146 3Lucy20 4Tom 118 5Tom 102 6Lucy90 7Lucy34 8John122 Let’s find the total score obtained by all players. Solution: SELECT SUM(score) as sum_score FROM game; Here’s the result:

How to Trim Strings in SQL

Problem: You’d like to remove specific characters from the beginning and end of a string in SQL. Example: Our database has a table named post with data in two columns: id and title. idtitle 1' News about dogs ' 3'Eurovision 2019 ' 4'New political climate' Let’s trim the title of each post to remove the unnecessary space at the beginning and end.

How to Count Distinct Values in SQL

Problem: You’d like to count how many different non-NULL values there are in a given column. Example: Our database has a table named customer with data in the following columns: id, first_name, last_name, and city. idfirst_namelast_namecity 1JohnWilliamsChicago 2TomBrownAustin 3LucyMillerChicago 4EllieSmithDallas 5BrianJonesAustin 6AllanDavisNULL Let’s find the number of different (and non-NULL) cities.

How to Eliminate Duplicate Rows in SQL

Problem: You’d like to eliminate any duplicate rows from the result set of a query so that each row appears only once. Example: Our database has a table named clothes with data in the following columns: id, name, color, and year_produced. idnamecoloryear_produced 1T-shirtyellow2015 2jacketblue2016 3jeansblack2015 4jacketblue2015 5jacketgreen2016 6jacketyellow2017 7hatyellow2017 Let’s get the non-repeated names and colors of clothes produced before 2017.

How to Find Duplicate Rows in SQL?

Problem: You have duplicate rows in your table, with only the IDs being unique. How do you find those duplicate entries? Example: Our database has a table named product with data in the following columns: id, name, and category. idnamecategory 1steakmeat 2cakesweets 3steakmeat 4porkmeat 5cakesweets 6cakesweets Let’s find duplicate names and categories of products.

How to Handle Divide by Zero In SQL

Problem: You want to perform division in your SQL query, but the denominator is an expression that can be zero. The database will give you an error when the denominator is in fact zero. Example: Our database has a table named investor_data with data in the following columns: id, investor_year, price_per_share, income, and expenses. idinvestor_yearprice_per_shareincomeexpenses 120162032002300 2201713020002000 3201840200100 420191559004900 Let’s divide the price per share by the difference between income and expenses to determine the P/E ratio (price-earnings ratio) for each year.

How to Join on Multiple Columns

Problem: You want to join tables on multiple columns by using a primary compound key in one table and a foreign compound key in another. Example: Our database has three tables named student, enrollment, and payment. The student table has data in the following columns: id (primary key), first_name, and last_name. idfirst_namelast_name 1EllieWillson 2TomBrown 3SandraMiller The enrollment table has data in the following columns: primary key (student_id and course_code), is_active, and start_date.

How to Multiply Two Columns in SQL

Problem: You want to multiply values from two columns of a table. Example: Our database has a table named purchase with data in the following columns: id, name, price, quantity, and discount_id. idnamepricequantitydiscount_id 1pen731 2notebook582 3rubber1131 4pencil case2423 Let’s multiply the price by the quantity of the products to find out how much you paid for each item in your order.

How to Order By Two Columns in SQL?

Problem: You need to display records from a given table sorted by two columns. Example: Our database has a table named employee with the following columns: id, first_name, last_name, and salary. idfirst_namelast_namesalary 1LisaUlman3000 2AdaMuller2400 3ThomasGreen2400 4MichaelMuller3000 5MaryGreen2400 Let’s display all information for each employee but sort the records according to salary in descending order first and then by last name in ascending order.

How to Order by Count in SQL?

Problem: You aggregated data into groups, but you want to sort the records in descending order by the number of elements in the groups. Example: Our database has a table named user with data in the following columns: id, first_name, last_name, and country. idfirst_namelast_namecountry 1LisaWilliamsEngland 2GaryAndersPoland 3TomWilliamsPoland 4MichaelBrownFrance 5SusanSmithUSA 6AnneJonesUSA 7EllieMillerPoland Let’s create a report on our users.

How to Order Alphabetically in SQL

Problem: You want to display records from a table in alphabetical or reverse-alphabetical order according to given column. Example: Our database has a table named customer. The customer table contains data in the id, first_name, and last_name columns. id first_name last_name 1 Susan Thomas 2 John Michael 3 Tom Muller Let’s display each customer’s information, sorted in ascending order by their last name.

Oracle Top-N Queries for Absolute Beginners

It's common to run a query using only part of a dataset – for example, the top 100 salespeople in a company. In this article, we'll see how to use Oracle's Top-N query method to query just these rows. Top-N queries retrieve a defined number of rows (top or bottom) from a result set. In other words, they find the best or worst of something – the ten best selling cars in a certain region, the five most popular routers, the 20 worst-performing stores, etc.

Oracle Collations: Binary and Linguistic Collations

Oracle bases its language support on the values of parameters that begin with NLS. These parameters specify, for example, how to display currency or how the name of a day is spelled. The table below presents some of the NLS parameters. By using one of them, NLS_SORT, we can specify the sort method (binary or linguistic) for both SQL WHERE clause operations and NLSSORT function operations. Option Name Description NLS_LANG The current language, territory, and database character set, which are determined by session-wide globalization parameters.

The Most Useful Date and Time Functions

Date and time functions and formats are quite different in various databases. In this article, let's review the most common functions that manipulates dates in an Oracle database. The function SYSDATE() returns a 7 byte binary data element whose bytes represents: century, year, month, day, hour, minute, second It's important to know that select sysdate from dual in SQL*Plus gives the same result as select to_char(sysdate) from dual because SQL*Plus binds everything into character strings so it can print it.

MySQL's group_concat Equivalents in PostgreSQL, Oracle, DB2, HSQLDB, and SQLite

The GROUP_CONCAT() function in MySQL MySQL has a very handy function which concatenates strings from a group into one string. For example, let's take a look at the children table with data about parents' and children's names. if (typeof VertabeloEmbededObject === 'undefined') {var VertabeloEmbededObject = "loading";var s=document.createElement("script");s.setAttribute("type","text/javascript");s.setAttribute("src", "https://my.vertabelo.com/js/public-model/v1/api.js");(document.getElementsByTagName("head")[0] || document.documentElement ).appendChild(s);} parent_name child_name John Tom Michael Sylvie John Anna Michael Sophie To get the names of children of each person as a comma-separated string, you use the GROUP_CONCAT() function as follows:

Tag: Order By

What Does ORDER BY 1 Mean in SQL?

Have you ever seen the "ORDER BY 1" syntax in SQL queries and wondered what it means? In this article, we'll explore this syntax, clarify its purpose, and make it easier to grasp. Whether you're an experienced SQL user or just starting to explore this language, you've likely encountered the ORDER BY clause before. In SQL, the ORDER BY clause is used to sort the rows in a table based on one or more columns.

Using GROUP BY and ORDER BY Together: A Guide

Untangling how to use two basic SQL clauses – GROUP BY and ORDER BY – in one query. GROUP BY and ORDER BY are basic SQL clauses. As such, they are taught relatively early in the learning process. And they usually don’t present a big hurdle to beginners. However, using GROUP BY and ORDER BY together can be confusing. By the end of this article, your confusion on this subject will go away.

SQL ORDER BY Clause with 7 Examples

Get to know the SQL ORDER BY clause! Our practical and easy examples will help you understand its syntax, common uses, and best practices. SQL or Structured Query Language lets you “talk” to a database. It enables you to create, retrieve and manipulate the data in a relational database. This language has become so ubiquitous that hardly any data-related field has been untouched by it. If you’re interested in the SQL ORDER BY clause, I’m assuming you have either already started learning SQL or are planning to start it soon.

How to Include Zero in a COUNT() Aggregate

Explaining how to include zero (0) counts in your SQL query result. Here’s the problem: you want to count something that doesn’t exist, and you want to show your result as zero. How do you do that in SQL? Using the COUNT() aggregate function is a reasonable first step. It will count all the data it finds and return the number of occurrences. But what if there are no occurrences of certain data?

How to Sort Values in a Specific Order in SQL

Sometimes you will be required to order your data in a particular way, and often the use of typical sort modifiers like ASC and DESC are not enough. This article will show you how to use the CASE statement to order your data exactly how you need it to be. Have you ever needed to order your data in a very specific way? One of the best methods for handling complex sorting is using CASE.

What Is the SQL GROUPING SETS Clause, and How Do You Use it?

GROUPING SETS are groups, or sets, of columns by which rows can be grouped together. Instead of writing multiple queries and combining the results with a UNION, you can simply use GROUPING SETS. GROUPING SETS in SQL can be considered an extension of the GROUP BY clause. It allows you to define multiple grouping sets in the same query. Let’s look at its syntax and how it can be equivalent to a GROUP BY with multiple UNION ALL clauses.

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.

What Does ORDER BY Do?

When analyzing data, it often helps to have rows ordered in a specific way. In this article, I’ll use multiple examples to show how SQL ORDER BY sorts data according to one or more columns in ascending or descending order. Introduction to ORDER BY By default, the order of rows in the output of an SQL query is arbitrary. If you want to sort the output in a particular order, you’ll need to use the ORDER BY keyword.

GROUP BY in SQL Explained

The SQL GROUP BY statement is easy to use, but it can be hard to master. Learn what you can do with GROUP BY, how it works, and how to use it with aggregate functions. GROUP BY is one of the basic SQL tools. However, it might be difficult for beginners to understand how GROUP BY works and how it is used to compute statistics with different aggregate functions. In this article, I’ll use several examples to show exactly how GROUP BY organizes rows and how aggregate functions can be used to calculate statistics on one or more columns.

How to Find Duplicate Values in SQL — The Ultimate Guide

Updated on: November 28th, 2023 Find duplicate values in SQL efficiently and avoid wasting resources. This article demonstrates how to locate and address duplicate records using SQL's GROUP BY and HAVING clauses. Database best practices usually dictate having unique constraints (such as the primary key) on a table to prevent the duplication of rows when data is extracted and consolidated. However, you may find yourself working on a dataset with duplicate rows.

How ORDER BY and NULL Work Together in SQL

Do NULL values come first or last when you use ORDER BY? Are they considered higher or lower than non-NULL values? In this article, I’ll explain how different relational databases treat NULL values when sorting output and how to change the default behavior of the ORDER BY clause. When LearnSQL users practice the ORDER BY clause in our SQL Basics course, they often ask why NULL values appear first in the output and how they can change this behavior.

Difference between GROUP BY and ORDER BY in Simple Words

For someone who is learning SQL, one of the most common places to get stuck is when learning the GROUP BY command. GROUP BY and ORDER BY are two important keywords in SQL that we use to organize data. The difference between GROUP BY and ORDER BY is that ORDER BY is more simple than GROUP BY and is usually introduced early in an SQL course. Sometimes, people are quite confused over these two concepts (SQL ORDER BY vs.

How to Sort Records with the ORDER BY Clause

Relational databases don't store records in alphabetical, numerical, ascending, or in any particular order. The only way to order records in the result set is to use the ORDER BY clause. You can use this clause to order rows by a column, a list of columns, or an expression. You can also order rows using the CASE expression. In this post, we'll take a look at the ORDER BY clause – how to write it, how it works, and what it does.

Tag: Over

Learn the OVER() Clause in SQL with 7 Examples

Learn how to use the OVER() clause in your SQL queries and you will take a step forward in your SQL knowledge. Most data analysts and SQL developers have a good handle on the SELECT, FROM, WHERE, GROUP BY, and ORDER BY clauses. However, these clauses are only a limited subset of the SQL language. There are other clauses, such as OVER(), which allow us to create flexible SQL reports and add an enormous expressive power to the SQL language.

The SQL OVER() Clause Explained

Here is a detailed explanation of the OVER() clause in SQL window functions. This is a detailed guide on using the OVER() clause in SQL window functions. I will focus specifically on this clause, which requires that you have at least a general idea of how window functions work. To make the best out of this article, take a look at the SQL Window Functions Cheat Sheet. Feel free to have it by your side as we go.

Tag: Partition By

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.

How to Use SUM() with OVER(PARTITION BY) in SQL

Discover real-world use cases of the SUM() function with OVER(PARTITION BY) clause. Learn the syntax and check out 5 different examples. We use SQL window functions to perform operations on groups of data. These operations include the mathematical functions SUM(), COUNT(), AVG(), and more. In this article, we will explain what SUM() with OVER(PARTITION BY) does in SQL. We’ll show you the most common use cases in real-world applications to determine the ratio of the individual row value to the total value, calculate running totals, and find a custom order total that includes discounts for certain products.

How to Use the PARTITION BY Clause in SQL

We’ll be dealing with the window functions today. Specifically, we’ll focus on the PARTITION BY clause and explain what it does. PARTITION BY is one of the clauses used in window functions. In SQL, window functions are used for organizing data into groups and calculating statistics for them. It sounds awfully familiar, doesn’t it? Even though they sound similar, window functions and GROUP BY are not the same; window functions are more like GROUP BY on steroids.

Differences Between GROUP BY and PARTITION BY

Window functions are a great addition to SQL, and they can make your life much easier if you know how to use them properly. Today, we will address the differences between a GROUP BY and a PARTITION BY. We’ll start with the very basics and slowly get you to a point where you can keep researching on your own. PARTITION BY vs. GROUP BY The PARTITION BY and the GROUP BY clauses are used frequently in SQL when you need to create a complex report.

Tag: Pivot

Useful SQL Patterns: Pivoting

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. The concept of pivot in SQL refers to taking the data in table rows and making that data into columns. This is very important in reporting, and it’s easy to do when you use the CASE statement.

Tag: Postgis

Free SQL Course of the Month – PostGIS

What is PostGIS, and why should you learn it? (Hint: Our SQL PostGIS course is free throughout June 2022!) Did you know databases can store geographic data? This is how interactive maps are made, most often based on PostGIS. In this article, I will tell you what PostGIS is and why it’s worth learning. Moreover, I am going to offer you an awesome online PostGIS SQL course which you can do for free during June 2022!

Tag: Postgresql

Free SQL Course of the Month – Revenue Trend Analysis in PostgreSQL

Need to understand what your data is saying about your business? In April 2024, our Free SQL Course of the Month is Revenue Trend Analysis in PostgreSQL. Don't miss this opportunity to elevate your analytical capabilities with a leading database system! Understanding revenue trends is crucial for business success, but effective data analysis can be challenging. Dive into the world of SQL reports and enhance your business growth strategies with PostgreSQL.

Free Course of the Month: PostgreSQL Window Functions

Are you looking for the best way to master SQL window functions? Throughout March 2024, you can access the interactive course Window Functions in PostgreSQL for free. Boost your skills at no cost. Hurry, time is running out! Need a free PostgreSQL course on window functions? You've come to the right place! If you are reading this article, you probably know PostgreSQL is one of the most popular databases in the world.

PostgreSQL Cheat Sheet

Here's your ultimate PostgreSQL cheat sheet! Whether you're a newbie or an experienced pro in need of a quick reference, this cheat sheet has got you covered. This PostgreSQL Cheat Sheet summarizes the key PostgreSQL commands and features you'll use often. It covers everything from how to connect to a PostgreSQL server and manage database contents, to the basic syntax for table creation and modification. It also breaks down the syntax for SELECT, INSERT, UPDATE, DELETE commands, and shows how to use different PostgreSQL functions, including text functions, numeric functions, NULL functions, and date and time functions.

Free Course of the Month: PostgreSQL Customer Behavior

Ever wondered how top businesses understand their customers so well? The secret lies in data analysis, and we're offering you the key – for free – in our Customer Behavior Analysis in PostgreSQL course! Are you familiar with the basics of PostgreSQL and eager to delve deeper into customer behavior analysis? Our November 2023 Course of the Month, Customer Behavior Analysis in PostgreSQL, has you covered! And the best part?

Free Course of the Month – SQL Practice Set in PostgreSQL

Do you know the basics of PostgreSQL but still need some practice? Look no further! Here is a great interactive course, SQL Practice Set in PostgreSQL. Throughout the month of September, you have access to it for FREE! We at LearnSQL.com believe that to learn a new skill, you need basic theoretical knowledge and, above all, a lot of practice. It's the same with writing PostgreSQL queries – you need a lot of PostgreSQL practice.

Free Course of the Month: Write Functions in PostgreSQL

Why learn to write user-defined functions? I’ll explain in this article – and how you can learn for free during July 2023 with this LearnSQL.com  PostgreSQL course! PostgreSQL is one of the most popular databases in the world. This is mainly due to its great functionality and the fact that it’s open source (i.e. free!). Postgres is fast, it runs on multiple systems, and it’s suitable for almost any application.

Course of the Month: INSERT, UPDATE, and DELETE in PostgreSQL

Do you want to be a data engineer or data analyst? Do you work with databases daily and need to expand your skills with the basics of data manipulation? You've come to the right place. For June 2023, our SQL course of the month is PostgreSQL INSERT, UPDATE, and DELETE Commands! Learn SQL for FREE! How do you get this free PostgreSQL course in June? Create a free LearnSQL.

Best PostgreSQL Courses for Beginners

So you want to learn PostgreSQL but aren't sure how to get started? In this article, we look at some of the best online courses available on the Internet for learning PostgreSQL, so you can get started right away! What Is PostgreSQL? PostgreSQL is used in major companies such as Apple and Instagram. You may be wondering: should I learn PostgreSQL? PostgreSQL is a popular dialect of SQL, or Structured Query Language, a programming language for accessing and managing data in relational databases.

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.

Free Course of the Month – PostgreSQL JOINs

Our PostgreSQL JOINs course will help you consolidate your knowledge of working with data from two or more tables in a PostgreSQL database. Throughout the month of February 2023, this awesome SQL course is absolutely FREE! Wondering why we want to give you this SQL course for free? We've been doing this for a long time. Every month, we choose one of our interactive online SQL courses and give users free access to it.

An Overview of SQL Text Functions in PostgreSQL

If you’re a PostgreSQL user and into data analysis, you’ve heard of the text functions or maybe even used them. But what are PostgreSQL’s most popular text functions? In today’s article, we’ll show you what they are and how to use them. As anyone who works with them knows, databases don’t contain only numerical values. Among other data types, databases also store text or string data. To use PostgreSQL effectively, you’ll have to know at least some of Postgres’ text functions.

PostgreSQL vs. MySQL: Is It Difficult to Switch?

So you know PostgreSQL, but the boss has decided to switch to MySQL. What are the differences between these two SQL dialects? We discuss PostgreSQL vs. MySQL in this article. PostgreSQL has gained popularity in the last decade, and many developers and database specialists learned PostgreSQL as their first SQL dialect. But PostgreSQL is not the only relational database; during your IT career, you will probably be asked to use another SQL dialect – like MySQL.

Switching from PostgreSQL to MS SQL Server

What are the differences in PostgreSQL vs. MS SQL Server? We discuss the similarities and the differences between these two popular SQL dialects. Many of us developers and database specialists began working with free relational databases like PostgreSQL or MySQL for personal projects or small organizations. Some of us have since moved on to organizations using MS SQL Server and have had to learn to use the new tool. You may be wondering how challenging that is and whether you would struggle with SQL Server under similar circumstances.

Free SQL Course of the Month – PostGIS

What is PostGIS, and why should you learn it? (Hint: Our SQL PostGIS course is free throughout June 2022!) Did you know databases can store geographic data? This is how interactive maps are made, most often based on PostGIS. In this article, I will tell you what PostGIS is and why it’s worth learning. Moreover, I am going to offer you an awesome online PostGIS SQL course which you can do for free during June 2022!

Is Learning PostgreSQL in 2022 Worthwhile?

You want to take a SQL course, but selecting the right one can be too challenging. Perhaps you don't know which dialect you should start with? PostgreSQL is one of the best options. Check out if it is worth it to learn PostgreSQL in 2022. When you search the web, there are many job advertisements for database specialists. Perhaps that is why you have chosen the direction toward development. Or maybe you are just fed up with Excel in your day-to-day duties (which is not surprising) and want to make work easier.

PostgreSQL Interview Questions and Answers

Job interviews are always stressful. Interviewing and getting asked technical questions about PostgreSQL is even more of a challenge! In this article, we’ll cover some of the PostgreSQL interview questions you can expect when applying for a new job. By the end of the article, you should be able to handle most of the questions you are likely to face. We’ve previously covered common questions you can expect at a SQL job interview, but this article will be focused on Postgres specifically.

SQL Date and Time Functions in 5 Popular SQL Dialects

Are you confused by all the date and time functions used across different SQL dialects? In this article, I summarize the date and time data types used in PostgreSQL, Oracle, SQLite, MySQL, and T-SQL. I also provide examples with the key SQL date and time functions used across these dialects. It’s time to become date and time gurus! Do you want to calculate how often employees are running late for work?

How to Order by Date in PostgreSQL or Oracle

Problem: You want to sort the rows by date in PostgreSQL or Oracle database. Example 1: The exam table has two columns, subject and exam_date. subjectexam_date Mathematics2022-12-19 English2023-01-08 Science2023-01-05 Health2023-01-05 ArtNULL You want to sort the rows by exam_date. Solution: SELECT * FROM exam ORDER BY exam_date; The result looks like this (the rows are sorted in ascending order by exam_date):

An Overview of PostgreSQL Data Types

It’s vital to know what you actually store in your database. That’s why every column has its data type. There are numerous PostgreSQL data types across various categories. Read on to see which data type suits which use case! In this article, we’ll go through the most common data types used in PostgreSQL. PostgreSQL, also called Postgres, is a well-known open-source object-relational database management system (DBMS). It is SQL-compliant, extensible, and includes all standard relational database features, such as database constraints, transactions, views, triggers, stored procedures, and more.

Breaking With Filing Cabinets: The History of PostgreSQL

This July, PostgreSQL turns 25. It has had an extensive influence on computing. Thanks to PostgreSQL, the world said “Goodbye!” to filing cabinets as the standard for storing and processing data. So, who created PostgreSQL, and how has it changed over the decades? There are quite a few PostgreSQL enthusiasts among my colleagues at LearnSQL.com. It is simply a great database solution. Why? It is free and open-source. So, you can use it for free, even for commercial uses.

New SQL Course: GROUP BY Extensions in PostgreSQL

Do you want to take your knowledge of PostgreSQL to the next level? I have something for you: LearnSQL.com’s new GROUP BY Extensions in PostgreSQL course! It will help you get even more out of your data and create better reports and summaries. Fasten your seat belts and prepare to see what GROUP BY can do when it’s turbocharged. First, I have to confess something. I am not objective – I think PostgreSQL is the best and coolest SQL dialect.

MS SQL Server vs. PostgreSQL: Which to Choose?

Choosing the DBMS you will use for a new project is a very important and difficult decision. Two popular choices are MS SQL Server and PostgreSQL. To help you decide which would be best for you, I'll compare their features, list pros and cons, and give you some examples. Your selection of database management system (DBMS) depends on the type of business or project you're implementing. First, you need to know:

How to Practice PostgreSQL Online

PostgreSQL is hot right now!If you want to join a community of people passionate about data, this open-source database system is something you need to try. Like everything we teach on LearnSQL.com, PostgreSQL requires practice. To profit from Postgres – as this dialect is sometimes called – you need to start with the basics. You can watch some tutorials on YouTube or read articles to get to know what a Database Management System (DBMS) is.

How to Calculate Timestamp Difference in PostgreSQL

Problem: You have two columns of the type timestamp and you want to calculate the difference between them. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between the arrival and the departure. The travel table looks like this: iddeparturearrival 12018-03-25 12:00:002018-04-05 07:30:00 22019-09-12 15:50:002019-10-23 10:30:30 32018-07-14 16:15:002018-07-14 20:40:30 42018-01-05 08:35:002019-01-08 14:00:00 Solution 1 (difference in days, hours, minutes, and seconds): SELECT id, departure, arrival, arrival - departure AS difference FROM travel; The result is:

Want to Learn Advanced PostgreSQL? Try This!

Why and how should you learn advanced PostgreSQL? I’ll give you some tips that will help you achieve your goals. Keeping up with technology is hard; anyone who has foolishly tried to do so can confirm this (me, for example!). Most of the time, it just doesn't work. And to be brutally honest, keeping up with all the technologies all the time is pointless. You shouldn’t know everything about everything; it’s better to know as much as you need within the technology you use or want to use.

How to Import CSVs to PostgreSQL Using PgAdmin

Do you work with data and use CSV files? Here is a practical guide on how to import such files into a PostgreSQL database using pgAdmin, one of the best PostgreSQL editors on the market. Let's get right into importing CSVs into a Postgres database. We’ll start by explaining what a CSV file is, then we’ll introduce you to pgAdmin and show you how to do the import process. Don’t worry – it’s easy!

How to Calculate Date Difference in PostgreSQL/Oracle

Problem: You have two columns of the date type and you want to calculate the difference between them in PostgreSQL or Oracle database. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between arrival and departure and the number of days from arrival to departure inclusively. The travel table looks like this: iddeparturearrival 12018-03-252018-04-05 22019-09-122019-09-23 32018-07-142018-07-14 42018-01-052018-01-08 Solution: SELECT id, departure, arrival, arrival - departure AS date_difference, arrival - departure + 1 AS days FROM travel; The result is:

How to Create a Table with a Foreign Key in SQL

Problem: You want to create a foreign key for a table in a database. Example: We would like to create a table named student that contains a foreign key that refers to the id column in the table city. Solution 1: Creating new table with single-column foreign key CREATE TABLE student ( id INT PRIMARY KEY, first_name VARCHAR(100) NOT NULL, last_name VARCHAR(100) NOT NULL, city_id INT FOREIGN KEY REFERENCES city(id) ); Discussion: To create a new table containing a foreign key column that references another table, use the keyword FOREIGN KEY REFERENCES at the end of the definition of that column.

How to Delete a Foreign Key Constraint in SQL

Problem: You want to delete a foreign key from a table in a database. Example: We want to remove the foreign key named fk_student_city_id from the table student. Solution: ALTER TABLE student DROP CONSTRAINT fk_student_city_id; Discussion: To delete a foreign key from a table, use the ALTER TABLE clause with the name of the table (in our example, student) followed by the clause DROP CONSTRAINT with the name of the foreign key constraint.

How to Group by Two Columns in SQL

Problem: You want to group your data by two columns so you can count some statistics. Example: In the order table, you have the columns order_date, product_id, customer_id, and number. You would like to count the number of products bought by each customer each day. The order table looks like this: order_dateproduct_idcustomer_idnumber 2023-11-25711 2023-11-251213 2023-11-265312 2023-11-26124 2023-11-26321 2023-11-261627 2023-11-26332 2023-11-27631 Solution: SELECT order_date, customer_id, SUM(number) AS products_number FROM order GROUP BY order_date, customer_id; The result is:

How to Calculate a Square Root in SQL

Problem: You want to find the square root of a number in SQ:. Example: You want to compute the square root of all numbers in the column number from the table data. number 9 2 1 0.25 0 -4 Solution: SELECT number, SQRT(number) AS square_root FROM data; The result is:

How to Group by Year in SQL

Problem: You want to group your data by year in SQL. Example 1: One of the columns in your data is transaction_date. It contains a date. You would like to group all your data by year and calculate the total money earned each year. The data table looks like this: transaction_datemoney 2018-03-251700 2019-09-12100 2018-07-141200 2018-01-05400 2019-06-082000 2020-03-061500 Solution 1: Displaying the year and the money earned SELECT EXTRACT(year FROM transaction_date) AS year, SUM(money) AS money_earned FROM data GROUP BY EXTRACT(year FROM transaction_date); The result is:

How to Make a Column Unique in SQL?

Problem: You would like to make a column unique in a given table in a database. Example: We would like to make the column name unique in the table product. The query below presents one way to do it. Solution 1: Creating new table with a UNIQUE constraint CREATE TABLE product ( id INT NOT NULL PRIMARY KEY, name VARCHAR(100) UNIQUE, producer VARCHAR(100), category VARCHAR(100) ); Discussion: In this example a given column (the column name) was made unique by adding the clause UNIQUE at the end of the column definition (name VARCHAR(100) UNIQUE).

How to remove a unique constraint in SQL?

Problem: You would like to remove a unique constraint from the column/columns in a table in a database. Example: We would like to drop the unique constraint in the table product from the column name. The statement below shows how to do it. Solution ALTER TABLE product DROP CONSTRAINT UQ_product_name In this example the table product is altered by using the ALTER TABLE clause. After this clause you enter the name of the table (in our example: product) and the clause DROP CONSTRAINT with the name of the unique constraint you want to remove.

How to Get Yesterday’s Date in PostgreSQL

Problem: You would like to display yesterday's date (without time) in a PostgreSQL database. Solution 1: Use subtraction SELECT CURRENT_DATE - 1 AS yesterday_date; Assuming today is 2023-09-24, the result is: yesterday_date 2023-09-23 Discussion: To get yesterday's date, you need to subtract one day from today's date. Use CURRENT_DATE to get today's date. Note that you don’t need brackets at the end of the CURRENT_DATE function.

Major Companies Using PostgreSQL: Purposes & Examples

Which companies use the open-source relational database management system PostgreSQL? Find out … and learn why you should be a PostgreSQL user too. You know the blue elephant logo. You have heard that PostgreSQL is a very good solution. But which companies use it? Here is a list of the largest IT and business companies that use PostgreSQL (or Postgres, for short). Multinationals worth billions of dollars can't be wrong, right?

How to Get Current Time (No Time Zone) in PostgreSQL

Problem: You’d like to get the current time in a PostgreSQL database. You don’t want the time zone offset. Solution: We’ll use the function LOCALTIME to get the current time without the time zone offset. SELECT LOCALTIME; Here’s the result of the query: 22:15:51.987914 Discussion: The PostgreSQL function LOCALTIME returns the current time on the machine running PostgreSQL. It returns it as a time data type in the hh:mm:ss.

How to Get the Current Date and Time (No Time Zone) in PostgreSQL

Problem: You’d like to get the current date and time in a PostgreSQL database. You don’t need the time zone offset. Solution: We’ll use the function LOCALTIMESTAMP to get the current date and time without any time zone information: SELECT LOCALTIMESTAMP; Here’s the result of the query: 2023-09-24 20:10:58.977914 Discussion: The PostgreSQL function LOCALTIMESTAMP returns the current date and time (of the machine running that instance of PostgreSQL) as a timestamp value.

How to Get the Day of the Year from a Date in PostgreSQL

Problem: You want to get the day of the year from a date or a timestamp column in PostgreSQL. Example: Our database has a table named software_sale with data in the columns id, software, and sale_date. idsoftwaresale_date 1Super Game X2019-09-15 2Browser X2019-10-15 3DB News2019-11-26 4MyPaintSoft2018-10-15 5New OS2019-10-15 Let’s count the number of software items sold by days of the year.

How to Convert a String to a Date in PostgreSQL

Problem: You’d like to convert a string containing a date to the PostgreSQL date data type. Example: Let’s convert a date string to the date data type instead of its current text data type. Solution: Here’s Example 1 of how to use the TO_DATE() function. This is the query you would write: SELECT TO_DATE('20230304', 'YYYYMMDD') AS new_date; And here’s the result of the query: new_date 2023-03-04 Let’s look at Example 2 of the TO_DATE() function.

How to Convert a String to a Timestamp in PostgreSQL

Problem: You’d like to convert a string containing datetime information to a timestamp in PostgreSQL. Let’s convert a string containing date, time, and time zone information to the timestamptz data type. Solution: We’ll use the TO_TIMESTAMP() function. Here’s the query you would write: SELECT TO_TIMESTAMP('2018/08/27/15:23:45', 'YYYY/MM/DD/HH24:MI:ss') AS new_timestamptz; Here’s the result of the query: new_timestamptz 2018-08-27 15:23:45+02 Discussion: Use the PostgreSQL function TO_TIMESTAMP() when you want to convert a string containing date and time data to the timestamp data type.

How to Extract the Week Number from a Date in PostgreSQL

Problem: You want to get the week number of a date or timestamp value in a PostgreSQL database. Example: Our database has a table named children with data in the columns id, first_name, last_name, and birth_date. idfirst_namelast_namebirth_date 1AngelaMichelin2018-01-01 2MartinJackson2002-07-26 3JustinClark2010-12-26 4FrankBarker2008-06-08 For each child, let’s get their first name, last name, and the week number of their birth date.

How to Find the Interval Between Two Dates in PostgreSQL

Problem: You’d like to find the difference between two date/datetime values in a PostgreSQL database. Example: Our database has a table named employment with data in the columns id, first_name, last_name, start_date, and end_date: idfirst_namelast_namestart_dateend_date 1BarbaraWilson2015-02-012023-10-30 2RobertAnderson2006-04-172016-12-20 3StevenNelson2010-06-012023-09-23 For each employee, let’s get their first and last name and the difference between the starting and ending dates of their employment.

How to Get the Current Date and Time with Time Zone Offset in PostgreSQL

Problem: You’d like to get the current date and time with time zone information from a PostgreSQL database. Solution: We can use either CURRENT_TIMESTAMP or NOW() to get the current date and time with the time zone offset. SELECT CURRENT_TIMESTAMP; Here’s the result of the query: 2023-09-15 13:13:12.118432+02 Discussion: CURRENT_TIMESTAMP returns the current date, time, and time zone offset (using the date, time, and time zone of the machine on which PostgreSQL is running).

How to Get the Current Date in PostgreSQL

Problem: You’d like to get the current date in a PostgreSQL database. Solution: We’ll use the function CURRENT_DATE to get the current date: SELECT CURRENT_DATE; Here’s the result of the query: 2019-10-24 Discussion: The PostgreSQL CURRENT_DATE function returns the current date (the system date on the machine running PostgreSQL) as a value in the 'YYYY-MM-DD' format. In this format, YYYY is a 4-digit year, MM is a 2-digit month, and DD is a 2-digit day.

How to Get the Current Time in PostgreSQL

Problem: You’d like to get the current time with its time zone offset in a PostgreSQL database. Solution: We’ll use the CURRENT_TIME function to get the current time and time zone information. Here’s the query you’d write: SELECT CURRENT_TIME; Here’s the result of the query: 16:10:11.232455-05 Discussion: The PostgreSQL function CURRENT_TIME returns the current time and time zone offset of the machine on which PostgreSQL is running. It is given as a value in the hh:mm:ss.

How to Group by Month in PostgreSQL

Problem: You'd like to group records by month in a PostgreSQL database. Example: Our database has a table named watch with data in the columns id, name, and production_timestamp. idnameproduction_timestamp 1watch2019-03-01 11:45:23 2smartwatch2019-09-15 07:35:13 3smartband2019-09-22 17:22:05 Solution: You can use the DATE_TRUNC() function to group records in a table by month. Here's the query you would write:

How to Concatenate Strings in SQL

Problem: You want to join strings from two columns of a table into one. Example: Our database has a table named student with data in the following columns: id, first_name and last_name. idfirst_namelast_name 1LoraSmith 2EmilBrown 3AlexJackson 4MartinDavis Let’s append the first name to the last name of the student in one string. Use a space between each name.

How to Filter Records with Aggregate Function AVG

Problem: You want to filter groups of rows in by the average value of a given column. Example: Our database has a table named product with data in the following columns: id, name, store and price. idnamestoreprice 1milkGreen Shop2.34 2breadClark’s Grocery3.56 3breadSuper Market4.15 4milkSuper Market1.80 5breadGrocery Amanda2.26 6milkViolet Grocery3.45 7milkClark’s Grocery2.10 8breadViolet Grocery2.

How to Filter Records with Aggregate Function COUNT

Problem: You want to find groups of rows with a specific number of entries in a group. Example: Our database has a table named product with data in the following columns: id, name and category. idnamecategory 1sofafurniture 2glovesclothing 3T-Shirtclothing 4chairfurniture 5deskfurniture 6watchelectronics 7armchairfurniture 8skirtclothing 9radio receiverelectronics Let’s find the category of products with more than two entries.

How to Filter Records with Aggregate Function SUM

Problem: You need to filter groups of rows by the sum of a given column. Example: Our database has a table named company with data in the following columns: id, department, first_name, last_name, and salary. iddepartmentfirst_namelast_namesalary 1marketingLoraBrown2300 2financeJohnJackson3200 3marketingMichaelThomson1270 4productionTonyMiller6500 5productionSallyGreen2500 6financeOlivierBlack3450 7productionJenifferMichelin2800 8marketingJeremyLorson3600 9marketingLouisSmith4200 Let’s find the names of departments that have sums of salaries of its employees less than 7000.

How to Filter Rows without NULL in a column

Problem: You want to find records without a NULL in a column. Example: Our database has a table named product with data in three columns: id, name, and price. idnameprice 1butterNULL 2milk2.35 3bread3.25 4cheeseNULL Let’s find the names and prices of products that have a price (without a NULL). Do this by using the IS NOT NULL operator.

How to Find Records with NULL in a Column

Problem: You want to find records with NULL in a column. Example: Our database has a table named children with data in four columns: id, first_name, middle_name, and last_name. idfirst_namemiddle_namelast_name 1JohnCarlJackson 2TomNULLThomson 3LisaAliceNULL 4AnneNULLSmith Let’s find the id, first name, and last name of children without a middle name (NULL in column middle_name). We use the IS NULL operator for this. Solution: SELECT id, first_name, last_name FROM children WHERE middle_name IS NULL; Here’s the result:

How to Find Rows with Maximum Value

Problem: You want to find rows which store the largest numeric value in a given column. Example: Our database has a table named student with data in the following columns: id, first_name, last_name, and grade. You want to find the students who have the highest grades. idfirst_namelast_namegrade 1LisaJackson3 2GaryLarry5 3TomMichelin2 4MartinBarker2 5EllieBlack5 6MarySimpson4 Solution: SELECT id, first_name, last_name, grade FROM student WHERE grade = (SELECT MAX(grade) FROM student); Here’s the result:

How to Find Rows with Minimum Value

Problem: You want to find rows which store the smallest numeric value in a column. Example: Our database has a table named weather with data in the following columns: id, city, and temperature. You want to find cities with the lowest temperature. idcitytemperature 1Houston23 2Atlanta20 3Boston15 4Cleveland15 5Dallas34 6Austin28 Solution: SELECT id, city, temperature FROM weather WHERE temperature = (SELECT MIN(temperature) FROM weather); Here’s the result:

How to Convert a String to Uppercase in SQL

Problem: You would like to convert a string to uppercase in SQL. Example: Our database has a table named questionnaire with data in the following columns: id, first_name, last_name, and favorite_car. idfirst_namelast_namefavorite_car 1AlanJacksonHonda Civic 2ElisaThomsonTOYOTA Camry 3MaryMartinesNissan rogue 4ChrisBrownford focus 5AdamSpringRam PICKUP Our table stores the make and model of the favorite car for each person who filled out our questionnaire.

How to Find the Average of a Numeric Column in SQL

Problem: You’d like to calculate the average of numbers stored in a column. Example: Our database has a table named sale with data in the following columns: id, city, year, and amount. idcityyearamount 1Los Angeles20172345.50 2Chicago20181345.46 3Annandale2016900.56 4Annandale201723230.22 5Los Angeles201812456.20 6Chicago201789000.40 7Annandale201821005.77 8Chicago20162300.89 Let’s calculate the average sales, regardless of city or year.

How to Find the Maximum Value of a Numeric Column in SQL

Problem: You’d like to find the maximum value of a numeric column. Example: Our database has a table named product with data in the following columns: id, name, year, and items. idnameyearitems 1bread roll2018345 2chocolate2017123 3butter201934 4bread roll2019456 5butter201856 6butter201778 7chocolate201987 8chocolate201876 Let’s find the maximum number of items sold over all years.

How to Find the Minimum Value of a Column in SQL

Problem: You’d like to find the smallest numeric value in a column. Example: Our database has a table named employment with data in the following columns: id, first_name, last_name, department, and salary. idfirst_namelast_namedepartmentsalary 1EllieMartinesmarketing1200 2MartinJohnsonfinance2300 3MichaelJacobsproduction1100 4StephenKowalskimarketing4300 5StanleyMillermarketing3500 6JenyBrownfinance5000 7MargaretGreenmarketing1500 8LisaThomasproduction2800 Let’s find the lowest salary among all employees.

How to Number Rows in SQL

Problem: You would like to give each row in the result table a separate number. Example: Our database has a table named furniture with data in the following columns: code (primary key) and name. codename 101bed 202sofa 333chair 123bookcase 235table 766desk The furniture table stores the name of pieces of furniture that we want to number.

What’s the Difference Between RANK and DENSE_RANK in SQL?

Problem: You want to compare the rankings produced by RANK and DENSE_RANK and add them as new columns to a table. Example: Our database has a table named sales_assistant with data in the following columns: id (primary key), first_name, last_name, month, and sold products. idfirst_namelast_namemonthsold products 1LisaBlack 52300 2MaryJacobs52400 3LisaBlack 62700 4MaryJacobs62700 5AlexSmith 62900 6MaryJacobs71200 7LisaBlack 71200 8AlexSmith 71000 Let’s display each sales assistant’s first and last name and number of sold products.

How to Add Rankings with DENSE_RANK() in SQL

Problem: You want to add a ranking position to rows consecutively, even if the rows have the same values. Example: Our database has a table named competition with data in the following columns: id (primary key), first_name, last_name, and score. idfirst_namelast_namescore 11JohnThomas345 14MaryJohnson222 16LisaBrown154 23AlanBlake222 32ChrisTaylor154 Let’s display all details about students: their last name, first name, and scores sorted by score in descending order.

How to Floor Numbers in SQL

Problem: You want to round a number down to the nearest integer. Example: Our database has a table named employee with data in the following columns: id, first_name, last_name, and hours_worked (for the current month). idfirst_namelast_namehours_worked 1AlanWatson95 2LisaBlack225 3LauraWilliams104 Let’s show the first and last name of each employee along with the number of days they worked.

How to Round Numbers in SQL

Problem: You want to round a number to a specific number of decimal places in SQL. Example: Our database has a table named product with data in the following columns: id, name, and price_net. idnameprice_net 1bread2.34 2croissant1.22 3roll0.38 Suppose there’s a tax of 24% on each product, and you’d like to compute the gross price of each item (i.e., after taxes) and round the value to two decimal places.

How to Round Up a Number to the Nearest Integer in SQL

Problem: You want to round up a number to the nearest integer in SQL. Example: Our database has a table named rent with data in the following columns: id, city, area, and bikes_for_rent. idcityareabikes_for_rent 1Los Angeles1302.151000 2Phoenix1340.69500 3Fargo126.44101 Let’s show each city’s name along with the ratio of its area to the number of bikes for rent.

How to Use LIKE in SQL

Problem: You need to search for specific patterns (certain combinations of letters or numbers) within text data in your database. We'll show you how to use the LIKE operator in SQL to: Find city names starting with S Find city names with exactly five characters Find city names starting with S and with o as the second-to-last character You'll also learn how to use LIKE and wildcard operators in SQL to find your own patterns in text data in your database.

How to Count the Number of Rows in a Table in SQL

Problem: You’d like to determine how many rows a table has. Example: Our database has a table named pet with data in the following columns: id, eID (electronic identifier), and name. ideIDname 123456sparky 223457mily 3NULLlessy 4NULLcarl 534545maggy Let’s count all rows in the table. Solution: COUNT(*) counts the total number of rows in the table:

How to Replace Part of a String in SQL

Problem: You’d like to replace part of a string with another string. Example: Our database has a table named investor with data in the following columns: id, company, and phone. idcompanyphone 1Big Market123–300-400 3The Sunny Restaurant123–222-456 4My Bank123-345-400 We’d like to change the phone number format for each company by replacing the hyphen character with a space.

How to Sum Values of a Column in SQL?

Problem: You’d like to sum the values of a column. Example: Our database has a table named game with data in the following columns: id, player, and score. idplayerscore 1John134 2Tom 146 3Lucy20 4Tom 118 5Tom 102 6Lucy90 7Lucy34 8John122 Let’s find the total score obtained by all players. Solution: SELECT SUM(score) as sum_score FROM game; Here’s the result:

How to Trim Strings in SQL

Problem: You’d like to remove specific characters from the beginning and end of a string in SQL. Example: Our database has a table named post with data in two columns: id and title. idtitle 1' News about dogs ' 3'Eurovision 2019 ' 4'New political climate' Let’s trim the title of each post to remove the unnecessary space at the beginning and end.

How to Count Distinct Values in SQL

Problem: You’d like to count how many different non-NULL values there are in a given column. Example: Our database has a table named customer with data in the following columns: id, first_name, last_name, and city. idfirst_namelast_namecity 1JohnWilliamsChicago 2TomBrownAustin 3LucyMillerChicago 4EllieSmithDallas 5BrianJonesAustin 6AllanDavisNULL Let’s find the number of different (and non-NULL) cities.

How to Eliminate Duplicate Rows in SQL

Problem: You’d like to eliminate any duplicate rows from the result set of a query so that each row appears only once. Example: Our database has a table named clothes with data in the following columns: id, name, color, and year_produced. idnamecoloryear_produced 1T-shirtyellow2015 2jacketblue2016 3jeansblack2015 4jacketblue2015 5jacketgreen2016 6jacketyellow2017 7hatyellow2017 Let’s get the non-repeated names and colors of clothes produced before 2017.

How to Find Duplicate Rows in SQL?

Problem: You have duplicate rows in your table, with only the IDs being unique. How do you find those duplicate entries? Example: Our database has a table named product with data in the following columns: id, name, and category. idnamecategory 1steakmeat 2cakesweets 3steakmeat 4porkmeat 5cakesweets 6cakesweets Let’s find duplicate names and categories of products.

How to Handle Divide by Zero In SQL

Problem: You want to perform division in your SQL query, but the denominator is an expression that can be zero. The database will give you an error when the denominator is in fact zero. Example: Our database has a table named investor_data with data in the following columns: id, investor_year, price_per_share, income, and expenses. idinvestor_yearprice_per_shareincomeexpenses 120162032002300 2201713020002000 3201840200100 420191559004900 Let’s divide the price per share by the difference between income and expenses to determine the P/E ratio (price-earnings ratio) for each year.

How to Join on Multiple Columns

Problem: You want to join tables on multiple columns by using a primary compound key in one table and a foreign compound key in another. Example: Our database has three tables named student, enrollment, and payment. The student table has data in the following columns: id (primary key), first_name, and last_name. idfirst_namelast_name 1EllieWillson 2TomBrown 3SandraMiller The enrollment table has data in the following columns: primary key (student_id and course_code), is_active, and start_date.

How to Multiply Two Columns in SQL

Problem: You want to multiply values from two columns of a table. Example: Our database has a table named purchase with data in the following columns: id, name, price, quantity, and discount_id. idnamepricequantitydiscount_id 1pen731 2notebook582 3rubber1131 4pencil case2423 Let’s multiply the price by the quantity of the products to find out how much you paid for each item in your order.

How to Order By Two Columns in SQL?

Problem: You need to display records from a given table sorted by two columns. Example: Our database has a table named employee with the following columns: id, first_name, last_name, and salary. idfirst_namelast_namesalary 1LisaUlman3000 2AdaMuller2400 3ThomasGreen2400 4MichaelMuller3000 5MaryGreen2400 Let’s display all information for each employee but sort the records according to salary in descending order first and then by last name in ascending order.

How to Order by Count in SQL?

Problem: You aggregated data into groups, but you want to sort the records in descending order by the number of elements in the groups. Example: Our database has a table named user with data in the following columns: id, first_name, last_name, and country. idfirst_namelast_namecountry 1LisaWilliamsEngland 2GaryAndersPoland 3TomWilliamsPoland 4MichaelBrownFrance 5SusanSmithUSA 6AnneJonesUSA 7EllieMillerPoland Let’s create a report on our users.

How to Order Alphabetically in SQL

Problem: You want to display records from a table in alphabetical or reverse-alphabetical order according to given column. Example: Our database has a table named customer. The customer table contains data in the id, first_name, and last_name columns. id first_name last_name 1 Susan Thomas 2 John Michael 3 Tom Muller Let’s display each customer’s information, sorted in ascending order by their last name.

How to Install PostgreSQL on Windows 10 in 5 Minutes

It may look like a complicated task to install PostgreSQL, Oracle, or SQL Server or any other database software, but it really isn’t! These days, most relational database management systems come with installation wizards that make the process much simpler. In this article, we’ll look at how to install PostgreSQL and test that the installation is working. Install PostgreSQL: Steps Involved To install PostgreSQL, we’ll complete the following tasks:

Extracting Data From a String: SPLIT_PART in PostgreSQL

Learn how to use split_part in PostgreSQL to extract data from strings. Quite often, we’d like to extract parts of a string when working with text values. A common example is when we have a full name and need to retrieve only the last name. In this article, we’ll examine how to do it using split_part in PostgreSQL, i.e. a string-related function that can be used to extract a substring.

The History of Slonik, the PostgreSQL Elephant Logo

Logos are powerful. What better way to remind people of a product than an eye-catching, memorable symbol? With that in mind, today we’ll answer the question ‘Why did PostgreSQL choose an elephant for its logo?’ Every product or company has its logo – something that identifies and encapsulates the essence of their brand. In time, it practically becomes the brand: can you imagine McDonald’s without its golden arches? What if the Coca-Cola logo was suddenly done in purple block print?

Your First Steps With the Geography Data Type

Geographical applications are everywhere: GPS and sat nav systems, maps, get-a-taxi apps, real estate portals, etc. Behind each of them is a spatial database storing geographical data, and supporting spatial queries. In this article, we will introduce PostGIS, the main open-source spatial database manager. PostGIS is a spatial database extension for the PostgreSQL relational database. It adds support for geographic objects, allowing location queries to be run in SQL. PostGIS adds two main data types to PostgreSQL: geography and geometry.

Pivot Tables in PostgreSQL Using the Crosstab Function

Some years ago, when PostgreSQL version 8.3 was released, a new extension called tablefunc was introduced. This extension provides a really interesting set of functions. One of them is the crosstab function, which is used for pivot table creation. That's what we'll cover in this article. The simplest way to explain how this function works is using an example with a pivot table. First, we will explain our initial point from a practical perspective, then we'll define the pivot table we want.

PostgreSQL Collations

List Collations Collations in PostgreSQL are available depending on operating system support. For example, in Ubuntu type the following to list the names of the available collations: locale -a The same locales are available in PostgreSQL in the pg_collation catalog (mappings from an SQL name to operating system locale categories). select * from pg_collation; collname | collnamespace | collowner | collencoding | collcollate | collctype -----------+---------------+-----------+--------------+-------------+------------ default | 11 | 10 | -1 | | C | 11 | 10 | -1 | C | C POSIX | 11 | 10 | -1 | POSIX | POSIX C.

DELETE RETURNING clause in PostgreSQL

The standard DELETE statement in SQL returns the number of deleted rows. DELETE FROM external_data; DELETE 10 In PostgreSQL you can make DELETE statement return something else. You can return all rows that have been deleted. DELETE FROM external_data RETURNING *; id | creation_date | user_id | data ----+---------------------------+---------+---------------- 101 | 2014-05-06 13:10:45.09484 | 23 | 'Some text' 102 | 2014-06-10 22:23:12.12045 | 25 | 'Some other text' (2 rows) DELETE 2

How to Select the First Row in a Group?

Often you want to select a single row from each GROUP BY group. PostgreSQL has a statement especially for that: SELECT DISTINCT ON. Let's say I want to select one weather report for each location. location time report Ottawa 2014-05-15 8:00 sunny 2014-05-15 11:00 cloudy 2014-05-15 15:00 rainy Warsaw 2014-05-15 8:00 overcast 2014-05-15 11:00 sunny 2014-05-15 15:00 rainy SELECT DISTINCT ON (location) location, time, report FROM weather_reports;

MySQL's group_concat Equivalents in PostgreSQL, Oracle, DB2, HSQLDB, and SQLite

The GROUP_CONCAT() function in MySQL MySQL has a very handy function which concatenates strings from a group into one string. For example, let's take a look at the children table with data about parents' and children's names. if (typeof VertabeloEmbededObject === 'undefined') {var VertabeloEmbededObject = "loading";var s=document.createElement("script");s.setAttribute("type","text/javascript");s.setAttribute("src", "https://my.vertabelo.com/js/public-model/v1/api.js");(document.getElementsByTagName("head")[0] || document.documentElement ).appendChild(s);} parent_name child_name John Tom Michael Sylvie John Anna Michael Sophie To get the names of children of each person as a comma-separated string, you use the GROUP_CONCAT() function as follows:

Tag: Practice Sql

A Chat with Anthony DeBarros, Author of Practical SQL

Some make model ships, others collect stamps. I read SQL books. I've read a lot of them, but only a very few deserve to be called really good. Some of them were included in my Best SQL Books list. The good news is that one of them just got a new release. It was great, even better than the previous edition! Moreover, I was able to talk to its author, Anthony DeBarros.

Tag: Preventing Mistakes

Preventing Common SQL Mistakes

Regardless of the engine you are using (SQL Server, MySQL, Oracle, etc.), you can prevent common errors and simplify the debugging process. This article will discuss some of the common SQL mistakes you’ll face and will help you correct them easily. One of the best ways to prevent the most common SQL mistakes is to keep your queries clear and readable. It’s very easy to forget the ideas behind your code!

Tag: Primary Key

Primary Key vs. Unique Key: Explaining the Differences

When designing a database, we often need to decide between defining a primary key vs. a unique key. Both of them are crucial during the design and further phases of a database. They allow us to uniquely identify each row, ensure the uniqueness of values in the column(s), and more. Let’s take a deep dive to learn more. This article will go through the primary and unique keys, their functions, and features.

Why Do You Need a Primary Key in a Database Table?

What is a primary key and why is it so important in SQL? Find out in this article. Primary keys are a central element in SQL databases. They provide a unique value that can identify a specific row in a table, which opens up a lot of other benefits. This article covers what a primary key is, how it works, and how to use it in an SQL database.

Tag: Programming

Efficient Data Analysis: Leveraging SQL with R

This article delves into the nuances of using SQL with R in data analysis. It offers insights and practical examples that demonstrate the effectiveness of this combination. By integrating SQL with R, analysts can leverage the strengths of both languages. This helps them perform comprehensive data analyses, going from initial data retrieval to complex statistical modeling and visualization. To kickstart our exploration of the dynamic duo of SQL and R in data analysis, it's essential to grasp how these two powerful tools can revolutionize the way we handle, manipulate, and interpret vast datasets.

Python vs. SQL for Data Analysis

You surely have heard about SQL and Python. Maybe you’ve even worked with one of those languages. Both have strengths and weaknesses. When it comes to data analysis, which should you use? This article will demonstrate how Python and SQL are useful for data analysis and how knowing both languages can boost your data analysis journey. Decided to get into data analytics? Great! An increasing number of companies are looking for people who can analyze data and draw conclusions from it.

Boost Data Potential wht SQL and Python

In this article, we will explain why using SQL with Python is an awesome combination for unleashing the full potential of your data! Read on to find out how learning and starting to use the most popular programming language can have a positive impact on your work. You may be wondering why we write about Python on the LearnSQL.com blog? Well ... They are just a very good couple. Both languages are basic tools in such fields as data science and data visualization.

How Developers Can Build SQL Skills

Even though you cannot build an application using SQL, employers continue to add SQL skills to their job requirements for software developers. In this article, I’ll elaborate on why developers need to know SQL and how you can learn SQL most efficiently. As a developer, you may work on different kinds of projects. Not all of your projects require doing string manipulation, but that doesn’t mean you don’t need to know how to do this.

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.

What Programming Language Should You Learn?

If you've ever been wondering which programming language you should learn first, you know that's a tough nut to crack. It’s especially difficult if you are new to IT and programming. In this article, I give suggestions for what to learn first and what perspectives each language can give you in IT. There are hundreds of programming languages, and new ones are showing up all the time. Getting to know all of them is simply impractical and impossible.

Tag: Range

RANGE Clause in Window Functions: 5 Practical Examples

What is a RANGE clause in SQL window functions? Five practical examples will show you how and when to use it. The RANGE clause is used quite rarely in SQL window functions. I don't know why; maybe people are not used to it. This is a shame, because it's far from a pointless clause; it can be very useful, and I'll show you that in five examples. To learn how window functions work, what functions there are, and how to apply them to real-world problems, it’s best to take the Window Functions course.

Tag: Rank

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.

What Is the RANK() Function in SQL, and How Do You Use It?

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.

Overview of Ranking Functions in SQL

SQL ranking functions make working with relational databases easier, especially for data analysts, marketers, and financial specialists. These functions are used to assign a ranking number for each record and allow you to efficiently create useful reports. SQL ranking functions are window functions. Window functions compute the result based on a set of rows. The word “window” refers to this set of rows. Let’s look at the syntax of ranking functions:

How to Rank Rows in SQL: A Complete Guide

Don’t struggle with SQL ranking functions anymore! This article will guide you through the most common ranking use cases. Rankings are used around us every day. Sports tournaments, the best movies and TV series on Netflix, stores with the cheapest products—these are only a few examples of rankings you might’ve seen recently. Using SQL RANK functions might be hard sometimes. The variety of different constructions is enormous. You can easily get lost in everything there is to learn about ranking.

Tag: Ranking

SQL Window Functions: Partitions and Ranking Functions

You’ve started your mastery of SQL window functions by learning RANK, NTILE, and other basic functions. In this article, we will explain how to use SQL partitions with ranking functions. Mastering SQL window functions (AKA analytical functions) is a bumpy road, but it helps to break the journey into logical stages that build on each other. In the previous Common SQL Functions article, you learned about the various rank functions, which are the most basic form of window functions.

Tag: Recursion

How to Write a Recursive CTE in SQL Server

A guide to understanding and using recursive CTEs in SQL Server SQL Server offers a lot of powerful tools for working with data, including Common Table Expressions (CTEs). A CTE is a temporary named result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement. CTEs can break down long queries into smaller, more manageable pieces of logic and make them more readable. SQL Server offers recursive Common Table Expressions.

Long SQL Query vs. Recursive SQL Query

Recursion is one of the central ideas in computer science. We can define it as a method for solving problems where the solution of the problem depends on solving a smaller instance of a problem. If this sounds complicated do not fret, in this article we will learn about recursion in SQL that you can practice and deepen in Vertabelo Academy. Recursion is a way of solving hierarchical problems we find in data with common SQL.

Tag: Recursive Queries

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?

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.

How to Learn SQL Common Table Expressions (CTEs)

Common table expressions are very useful for organizing, traversing, and improving the readability of long SQL queries.  Moreover, recursive CTEs, which can reference themselves, solve problems that cannot be addressed with other queries. But how do you master common table expressions in SQL? In this article, I discuss the most effective strategies for learning CTEs and suggest how to address the common challenges of learning common table expressions on your own.

How CTEs Work

The SQL language offers a feature named Common Table Expressions, or CTEs. Also known as WITH clauses, CTEs are a fairly new addition to SQL. They help you break longer queries into smaller chunks, making your queries much easier to understand. Read the article to find out how to use CTEs and how they differ from traditional subqueries. Common Table Expressions (CTEs), which are essentially named subqueries, were first mentioned in the SQL standard between 1999 and 2000.

How to Draw a Christmas Tree in SQL

You can use SQL to manipulate all kinds of data, from huge analytical queries to brief single-purpose statements. But you can also use SQL just for fun, without any business requirements stifling your creativity. So, get out your jolly hat and prepare to sing O Christmas Tree as we create some quirky art with plain old SQL. Today, we’re going to generate some holiday-themed ASCII art, just for fun. That’s right.

Simplify SQL Code: Recursive Queries in DBMS

Hey SQL users! Are you repeating the same query in every report? Are your queries getting too complicated? Use recursive queries to simplify SQL code! Too many SQL reports can lead to clutter on your desktop and in your head. And is it really necessary to code each of them separately? Ad-hoc queries can share much of the same SQL code with managerial reports and even regulatory reports. Suppose you’ve been writing basic SQL code for a while.

How to Organize SQL Queries with CTEs

Common table expressions (CTEs) allow you to structure and organize SQL queries. Knowing how to organize SQL queries is a necessity when you begin to move deeper into SQL, so if you want to become an SQL master, you need to know CTEs. The SQL CTE has been part of standard SQL for some time now. CTEs – which are also called WITH statements – are available in all major RDBMS.

Long SQL Query vs. Recursive SQL Query

Recursion is one of the central ideas in computer science. We can define it as a method for solving problems where the solution of the problem depends on solving a smaller instance of a problem. If this sounds complicated do not fret, in this article we will learn about recursion in SQL that you can practice and deepen in Vertabelo Academy. Recursion is a way of solving hierarchical problems we find in data with common SQL.

How Recursive Common Table Expressions Work

Recursive Common Table Expressions are immensely useful when you're querying hierarchical data. Let's explore what makes them work. Common Table Expressions (CTEs) are some of the most useful constructions in SQL. Their main purpose is improving query design, which makes queries easier to read. One of the reasons CTEs are so popular is that they let you divide longer queries into shorter subqueries. These are easier to read and edit.

Tag: Recursive Query

Get to Know the Power of SQL Recursive Queries

Most commonly, the SQL queries we run on a database are quite simple. Well, that depends on your role, of course. Analysts in data warehouses retrieve completely different sorts of information using (very often) much more complicated queries than software engineers creating CRUD applications. However, sometimes it's simpler or more elegant to run a query that is a little bit more sophisticated without needing further data processing in the code.

Tag: Relational Databases

53 Years of Relational Databases

If it weren't for him, there would be no modern databases. It is the 53st anniversary of the publication of his article that changed the rules of the game. Edgar Frank Codd is one of the fathers of SQL, and his name is one of the first to be mentioned in the history of databases. Or maybe even the history of computer development in general? See what we owe to Dr.

Tag: Reporting

Here’s How I Started Creating SQL Reports

Once upon a time, there was a girl who was just starting her adventure with learning SQL. As a marketer, one of her tasks was writing reports. Previously, she used Excel, a calculator, and written notes to prepare the reports her boss required. One day, it turned out that she could do her job much faster and easier. That was the day she read about SQL reports for the first time.

Why You Should Use SQL in Marketing Analytics

Have you been wondering how you could use SQL in your marketing data analysis work? Would you like to create SQL reports to guide your marketing decisions? In this article, you will learn how to use SQL for marketing through plenty of use cases. Are you a marketing professional wanting to better understand the results of your marketing efforts? Do you want better means to prove your point and demonstrate the value you create?

SQL Track of the Season: SQL Reporting in MS SQL Server

It's the best time of the year for a change! Learn something new and boost your career! This is our SQL Track of the Season: SQL Reporting in MS SQL Server! In this article, we’ll answer common questions about this track. Summer is here. Does the sun make you want to learn something new? Maybe surfing or Portuguese? Maybe you've wanted to learn crocheting all your life? Follow your dreams!

Tag: Reporting With Sql

Analyzing Survey Data: Explore Results Using SQL

Excel is a powerful beast that lets you analyze complex data. Yet, operating on big chunks of data can sometimes be a daunting task. Let's take a look at how SQL can help. Today, we'll tackle a common problem with importing data to an SQL database, using a real-life example. Suppose your company conducted a survey on the most popular programming trends and preferences, striving to meet the expectations of its users.

SQL Hacks To Control Family Budget On Black Friday Weekend

If you’re in the US, chances are you’ve been eagerly awaiting the approach of Black Friday just as much as Thanksgiving. Though the shopping frenzy takes hold of nearly everyone, some people have to stick to their budgets and shop prudently. In this article, we’ll take a look at how generating an SQL report can help you track how much your family spent shopping on Black Friday. Storing Black Friday Purchases in a Database Before we can create an SQL report, we first need some data we can use.

SQL Reporting Guide for Business Professionals

Working with the financial aspects of large and small enterprises can be a daunting task for a business professional. In this article, we'll look at several ways of constructing the perfect SQL report. You've probably already heard about SQL from your colleagues or in other areas of your career. If you're here, you've likely concluded that learning SQL will make your professional life easier – and you're right!

Tag: Reports

How to Start Writing SQL Reports

Updated on: April 23, 2024 So, you’ve started, or want to start, learning SQL. You understand that a database is a repository for raw data and that data in business forms the backbone of the decision-making process. But how do you gain meaningful insights from raw data? How can you take a vast amount of information from a database and use SQL to give it a real-world utilization? Learn how to write SQL reports!

Tag: Revenue Growth

Business SQL: How to Calculate Revenue Growth in SQL

Can you use SQL in business? Of course you can! For example, you can calculate revenue growth in SQL – here’s how. As someone who works with data, you already know that SQL is the most used tool in data analysis. But how is SQL helpful in business use? Well, the answer is obvious: analyze business data using SQL! However, there are some specifics with business data that can be tricky if you’re not used to it.

Tag: Review

Book Review: “Learn SQL the Hard Way” by Zed A. Shaw

“Learn SQL the Hard Way” by Zed A. Shaw is a great ebook for those who want to learn SQL essentials. At $19.99 USD, it may seem a bit expensive for an ebook, but you’re getting a DRM-free PDF, plus a whole bunch of explanatory videos and additional files. Who should read “Learn SQL the Hard Way”? Anyone interested in SQL basics – modifying databases or selecting information. Make no mistake about it: this book focuses heavily on the practical side of database language.

Tag: Rolling Average

What Is a Rolling Average and How Do You Compute It in SQL?

In this article, we will show three different examples of using SQL to calculate rolling averages. Learn this and you will take an important step in your SQL growth! A rolling average is a metric that allows us to find trends that would otherwise be hard to detect. It is usually based on time series data. In SQL, we calculate rolling averages using window functions. First, let’s talk about what rolling averages are and why they’re useful.

Tag: Round

How to Use the ROUND() Function in SQL

Need to round numeric results in SQL? The ROUND() function is here to do the job. Modern relational databases offer many built-in functions that extend the capabilities of SQL. In this article, we will use practical examples to explain how the ROUND() function works. (Spoiler alert: If you guessed that it rounds a number to a certain decimal place, you’re right! Read on to find out more.) SQL Standard Functions Each SQL database (PostgreSQL, MySQL, Oracle, SQL Server among others) has a set of built-in functions.

Tag: Saas Kpi Metrics

How to Use SQL to Calculate Customer Lifetime Value (LTV)

Working with data is an essential skill for marketers in today's data-driven world. As a marketer myself, I decided to create a series of articles about calculating key performance indicator (KPI) metrics for SaaS (Software as a Service) companies. We’ll start by calculating customer lifetime value (LTV) using SQL. Data is one of today’s most valuable resources. If you work in a SaaS company, you are flooded with a huge amount of data every day.

Tag: Select

What Is the UPDATE Statement in SQL?

The SQL UPDATE statement is used to update existing data in your database. This article will explain its syntax and show you clear examples of the UPDATE statement in action. Effectively updating existing data in a database is required for anyone using SQL; data is only useful if it is kept up-to-date and relevant. In this article, we’ll examine the syntax of the UPDATE statement in great detail. Then we’ll dive into detailed step-by-step examples that will drive home the rules, potential uses, and limitations associated with the SQL UPDATE statement.

An Overview of SQL Text Functions

In this article, we will discuss the ins and outs of the most common SQL text functions, which make it possible for you to find and work on string values. Before we dive into text functions, let’s quickly recap what an SQL function is. Simply put, a function is a predefined built-in piece of code that you can use in your SQL query. For example, the functions SUM(), AVG(), and COUNT() are applied to numerical variables to calculate the sum, average, and number of records respectively.

How Do You Write a SELECT Statement in SQL?

SQL is a language to communicate with relational databases, and the SELECT statement is the first thing you’ll learn when you start using SQL. In this article, you’ll learn how to write SELECT statements, from the basics to more advanced. What Is SQL? SQL stands for “Structured Query Language.” It has a long history that started in the 1970s. Being the standard for communication with relational databases, it has maintained its popularity.

How To Learn The SELECT Statement in SQL

When you think about learning SQL, one of the first things you come across is the SELECT statement. Selecting information is arguably the most important SQL feature. In this article, we’ll demonstrate the typical use cases for SQL SELECT with practical examples. Read this article if you’re a beginner database user and would like to know what SELECT can do for you. SQL, or Structured Query Language, is the programming language the IT world uses to communicate with databases.

Using CASE to Add Logic to a SELECT

As you write an SQL query, you may need to get values from multiple columns and change values from one form to another. The simple way to achieve this goal is to add a CASE expression to your SELECT statement. In this article, we'll introduce you to the syntax, formats, and uses of the CASE expression. The CASE expression is a conditional expression: it evaluates data and returns a result.

Tag: Skewness

High Performance Statistical Queries –Skewness and Kurtosis

In descriptive statistics, the first four population moments include center, spread, skewness, and kurtosis or peakedness of a distribution. In this article, I am explaining the third and fourth population moments, the skewness and the kurtosis, and how to calculate them. Mean uses the values on the first degree in the calculation; therefore, it is the first population moment. Standard deviation uses the squared values and is therefore the second population moment.

Tag: Software Development

I’m a Software Developer. How Do I Learn SQL?

What do you need to know about relational databases and SQL as a software developer? In this article, we’ll explain the topics you need to know and how you can acquire this knowledge. If you are a software developer, you may have noticed that SQL skills are often required in some development roles. Although you are not a database manager or a data scientist, you will need solid SQL foundations to continue your developer journey.

Tag: Sorting Records

How to Sort Records with the ORDER BY Clause

Relational databases don't store records in alphabetical, numerical, ascending, or in any particular order. The only way to order records in the result set is to use the ORDER BY clause. You can use this clause to order rows by a column, a list of columns, or an expression. You can also order rows using the CASE expression. In this post, we'll take a look at the ORDER BY clause – how to write it, how it works, and what it does.

Tag: Spreadsheet

SQL in Google Sheets? Yes, We Can!

Did you know that you can write SQL-like queries in Google spreadsheets? This feature is incredibly powerful, versatile, and can replace most of the functionalities offered by Excel’s pivot tables. Read our article to find out how you can easily use the QUERY function to efficiently work with your Google Sheets data. Relational databases share many features with spreadsheets. When we explain what databases are, we often say that they are a bit like spreadsheets except they give us more control over larger amounts of data.

Tag: Sql

SQL LEAD Function

Get to know the SQL LEAD function, an important function to know for anyone working with SQL in data analysis. Learn through examples how to use this function in practice. The SQL LEAD function is a very important and useful SQL window function. SQL window functions are essential for doing efficient data analysis. They allow you to work with groups of rows and single rows at the same time. They make writing complex reports easier.

SQL Track of the Season: SQL from A to Z in MySQL

Do you feel the spring already? Everything is in full bloom at this time of the year. Why shouldn’t it be the same with your career? You just need to water it with a new skill. Here is the brilliant SQL from A to Z in MySQL track, our Track of the Season. In this article, I answer common questions about this awesome set of online MySQL courses. Why should you care about relational databases at all?

Enhancing Decision-Making with SQL

If you’ve ever felt overwhelmed by inefficient workflows, there’s hope. In this article, I'll show you how smart decision-making with SQL can boost your career. You will explore practical SQL strategies that go beyond organizing data, and fundamentally transforming decision-making in your company. Are you a business professional keen on boosting your data management skills? Well, SQL—or Structured Query Language—might just be your ticket to greater efficiency. It’s a robust tool that can transform the way you interact with data.

SQL MAX Function

Learn about the SQL MAX function, which is used to find the highest value in your dataset. This article explains how to use the syntax of MAX function and shows typical usage examples. The SQL MAX function is an aggregate function that returns the maximum value in a column. MAX function, together with its counterpart MIN function, is useful for summarizing data in data analysis. It can help you to compute the range of values in a dataset.

Free Course of the Month: PostgreSQL Window Functions

Are you looking for the best way to master SQL window functions? Throughout March 2024, you can access the interactive course Window Functions in PostgreSQL for free. Boost your skills at no cost. Hurry, time is running out! Need a free PostgreSQL course on window functions? You've come to the right place! If you are reading this article, you probably know PostgreSQL is one of the most popular databases in the world.

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.

4th Anniversary of LearnSQL.com

Time runs so fast. This week, we celebrate the 4th anniversary of LearnSQL.com. We have come a long way together and we promise to get even better in the upcoming year! Thank you for being with us. 1459 days have passed since February 23, 2020, when we launched the LearnSQL.com platform. That's 35,016 hours, or 2,100,960 minutes, if you prefer. It's been a long time, but it feels like yesterday that we started out together.

9 Practical Examples of SQL LEFT JOIN

LEFT JOIN is one of SQL's most common JOINs. Make sure you know all its ins and outs by going through all nine of our real-life LEFT JOIN examples. LEFT JOIN – alongside INNER JOIN – is one of the essential SQL tools you need to work with data from two or more tables. But how and when should you use it? These nine LEFT JOIN examples will point the way.

Free Course of the Month – Common Functions in PostgreSQL

Do you want to be able to use popular PostgreSQL functions and process different types of data more easily? You've come to the right place! Here is the Common Functions in PostgreSQL course. Throughout the month of February, this SQL course is absolutely FREE! You are probably wondering why LearnSQL.com is offering a free SQL course. Well, we've been doing this for a long time. We choose one of our courses every month and give users free access to it.

This Advanced SQL Course Will Boost Your Career!

Can you already create pretty good SQL reports? Do you want to take it a step further? In this article, I'll explain how an advanced SQL course can propel you (and your career) to the next level. Since you are looking for information about SQL, you probably already know how important data is nowadays. Very few companies can stay on the market without using the power of data or basing their strategic decisions on it.

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.

What Are SQL Window Functions?

Need to up your data analysis game? Learn these SQL window functions here and you’ll take your analysis skills to the next level. Practice exercises and detailed explanations included! When I first heard about SQL window functions, I thought it was some strange marriage between SQL and Windows. I was wrong. The SQL window functions have nothing to do with that famous operating system. They are SQL functions that do computations on the set of rows related to the current row.

SQL for Human Resources

Data is just as important in Human Resources as it is in other business areas. That makes SQL for HR more than just a tool; it's a game-changer. Let's dive into this transformative journey together. In the modern business world, data has become a cornerstone. It drives decisions, shapes strategies, and offers insights that were previously out of reach. Every corner of an organization, every department, is tapping into the potential of data to enhance its operations.

Why Learn SQL?

In a world overflowing with data, SQL is the key to making sense of it all. It's the bridge between raw numbers and meaningful insights. In this article, I'll explore SQL’s unmatched value in our data-centric era. Let's answer the question: "Why learn SQL?" Every day, businesses and individuals generate and interact with vast amounts of data, seeking insights and solutions. Amidst this data-driven environment, a pressing question arises: Why learn SQL?

What Does ORDER BY 1 Mean in SQL?

Have you ever seen the "ORDER BY 1" syntax in SQL queries and wondered what it means? In this article, we'll explore this syntax, clarify its purpose, and make it easier to grasp. Whether you're an experienced SQL user or just starting to explore this language, you've likely encountered the ORDER BY clause before. In SQL, the ORDER BY clause is used to sort the rows in a table based on one or more columns.

BigQuery Window Functions Explained

Keeping up with data analysis trends gives your organization – and your CV – the cutting edge. In this article, we'll look at BigQuery window functions and how you can use them to gain deeper insights into your data. Google's BigQuery, launched in 2010, is gaining traction as a popular choice with organizations needing to analyze large quantities of information quickly and to compare their own data against statistical data in the public domain.

Free Course of the Month: Blog & Traffic Data

Why practice SQL with real-life scenarios? We'll explain in this article – and we’ll show how you can do it for free during October 2023 with this LearnSQL.com course! SQL is the backbone of many data-driven applications and businesses. It's a powerful language that allows you to interact with databases, retrieve data, and make insightful decisions. If you're looking to improve your SQL skills, our Basic SQL Practice: Blog & Traffic Data course is the perfect opportunity.

Python vs. SQL for Data Analysis

You surely have heard about SQL and Python. Maybe you’ve even worked with one of those languages. Both have strengths and weaknesses. When it comes to data analysis, which should you use? This article will demonstrate how Python and SQL are useful for data analysis and how knowing both languages can boost your data analysis journey. Decided to get into data analytics? Great! An increasing number of companies are looking for people who can analyze data and draw conclusions from it.

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.

Free Course of the Month – SQL Practice Set in PostgreSQL

Do you know the basics of PostgreSQL but still need some practice? Look no further! Here is a great interactive course, SQL Practice Set in PostgreSQL. Throughout the month of September, you have access to it for FREE! We at LearnSQL.com believe that to learn a new skill, you need basic theoretical knowledge and, above all, a lot of practice. It's the same with writing PostgreSQL queries – you need a lot of PostgreSQL practice.

How SQL Helps the Healthcare Sector

Why does the healthcare industry need SQL? Find out how you can use SQL for healthcare in this article. The digital age has ushered in a new era where data is at the heart of every industry. From finance to retail, data drives decision-making and strategy, shaping the way businesses operate and grow. The healthcare sector, with its vast and complex data sets, is no exception to this trend. The rise of digital health records, patient databases, and common integration of hospital inventory management software has underscored the importance of efficient data management in healthcare.

How AI & SQL Can Accelerate Your Data Analysis Workflow

Did you know that using AI for data analysis can be a total game changer for SQL developers and data analysts? In this article, we’ll learn about how AI can help you level up your data analysis skills and why it’s a must-have tool in every data professional’s toolkit. Artificial Intelligence (AI) has emerged as a game-changer in the workforce, transforming industries and redefining how professionals deal with data. Specifically, the use of AI for data analysis is becoming increasingly critical in making informed decisions.

SQL for Data Analysis Cheat Sheet

Welcome to our SQL for Data Analysis Cheat Sheet — a must-have resource for anyone looking to harness the power of SQL in the realm of data analysis. Whether you're a data enthusiast, a business analyst, or a seasoned data professional, this cheat sheet is designed to empower you to extract valuable insights from your datasets. Inside, you'll find a carefully curated collection of SQL commands and tips that will elevate your data analysis game.

New Feature: Notebook to Boost Your SQL Learning

You want to learn SQL effectively but you keep forgetting queries? Now you can use  LearnSQL.com’s new notebook feature in all our courses! This new tool will help you memorize and recall content. I remember when I first started to learn SQL. I was moving quite smoothly through most of the lessons, taking a lot of notes in my paper notebook. (I have a lot of old school paper notebooks).

How to Prepare for an Advanced SQL Interview

Tips and tricks to help you ace even the most advanced SQL interview questions. SQL has become the lingua franca of data – the standard method for interacting with databases, extracting insights, and conducting analytical tasks. As a data analyst, the ability to understand and manipulate SQL code is not just a 'nice to have'; it's an absolute necessity. For many data analyst roles, a basic understanding of SQL isn't enough.

20 Basic SQL Query Examples for Beginners

These 20 basic queries are a must in a starter pack for every SQL beginner. These examples will get you going on your journey to mastering SQL. You’ve set your mind on learning SQL, googled ‘basic sql query examples’ or something similar, and here you are staring at this article. Now what? All learning starts with the basics, so let’s start with the most basic question: What Is SQL?

Advanced SQL Practice: 10 Exercises with Solutions

As SQL proficiency continues to be in high demand for data professionals and developers alike, the importance of hands-on practice cannot be emphasized enough. Read on to delve into the world of advanced SQL and engage in practical exercises to enhance your skills. This article provides you with a collection of ten challenging SQL practice exercises specifically for those seeking to enhance their advanced SQL skills. The exercises cover a selection of SQL concepts and will help you refresh your advanced SQL knowledge.

What Does GROUP BY 1 and GROUP BY 1, 2, 3 Mean in SQL?

Have you ever come across the unfamiliar GROUP BY 1 syntax in SQL queries and wondered what it's all about? Well, you're not alone! In this article, we'll dive into this syntax, explain its purpose, and make it easier to understand. Whether you are a regular SQL user or you’re just beginning to learn this language, you have probably worked with GROUP BY before. The GROUP BY clause in SQL is used to group rows from a table based on one or more columns.

Best SQL Books for Data Analysis

In the world of data analysis, SQL is a powerful tool. It's a language that helps professionals find, organize, and analyze the data stored in databases. If you're looking to learn this important skill, you've come to the right place. This article will guide you through the best SQL books for data analysis, whether you're just starting out or already have some experience. SQL (Structured Query Language) is a standard language used for working with databases.

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.

Free Course of the Month – Window Functions Practice Set

Do you want to enhance your SQL skills and learn how to prepare complex SQL reports? Maybe you've learned SQL window functions but need a refresher. This month, our unique SQL course Window Functions Practice Set is completely free! You're probably wondering ‘What's the catch?’. Why do we give something for free to our users? Well... we want to support people like you who are constantly striving to be better.

The Best Way to Learn SQL: A Complete Guide for Beginners

If you've ever wondered about the best way to learn SQL, you're in the right place. Whether you're a complete beginner or an experienced professional looking to upskill, this comprehensive guide will show you the way. In today's data-driven world, you can think of data as a treasure chest full of gold. And SQL (Structured Query Language) is your personal key to unlocking it. SQL is a potent tool that allows you to communicate with databases, enabling you to extract, shape, and make sense of data.

Using GROUP BY and ORDER BY Together: A Guide

Untangling how to use two basic SQL clauses – GROUP BY and ORDER BY – in one query. GROUP BY and ORDER BY are basic SQL clauses. As such, they are taught relatively early in the learning process. And they usually don’t present a big hurdle to beginners. However, using GROUP BY and ORDER BY together can be confusing. By the end of this article, your confusion on this subject will go away.

SQL for Data Analysis: What Should I Learn?

You may already be aware of SQL's importance in data analytics. But what features of SQL are important to data analysis and where can you learn them? In this article, we will answer your questions. Before we talk about using SQL for data analysis, it helps to know what we’re talking about. So, let’s define these two things. Structured Query Language (SQL) is a programming language that is used to manage data in relational databases.

How to Master SQL

You've heard SQL is a must-have skill for furthering your career. You want to learn it. In this article, we look at why it is so beneficial to master SQL and how you can reach that level of mastery. Master SQL, and unlock the power of relational databases, the most used databases for managing structured data. But what makes SQL so important? SQL, or Structured Query Language, is a must-have skill for anybody navigating today's data-driven world.

Google BigQuery SQL Syntax: A Comprehensive Guide

What is Google BigQuery? What can it do for your organization? Is BigQuery SQL a valuable skill? Where can you learn it, and where can you get some practice? Very few organizations today are not computerized. Many processes now make use of the IoT (Internet of Things), where all kinds of devices are networked and continually feed real time data into computer systems. The result is a vast amount of data available for decision-making.

Our New Interactive Course – SQL Practice: University

Are you a beginner looking for a hands-on online SQL course to solidify your skills? Or perhaps you're an SQL learner hungry for real-world applications of your new skills? LearnSQL.com, has crafted a robust practice-based learning experience to help you advance at your own pace. Here is SQL Practice: University! In today's data-driven world, mastering SQL is more than just a useful skill—it's a powerful tool that can open doors to many career opportunities.

How E-Commerce Businesses Can Benefit From SQL

Learn how SQL for e-commerce can empower your online business. When we talk about business in the modern age, the phrase "knowledge is power" takes on a whole new dimension. In the world of e-commerce, the real power lies in the ability to leverage data; one of the key tools in the arsenal of data management and analysis is SQL. SQL, or Structured Query Language, is essential for e-commerce businesses looking to extract valuable insights from their vast reserves of data.

Free Course of the Month: Write Functions in PostgreSQL

Why learn to write user-defined functions? I’ll explain in this article – and how you can learn for free during July 2023 with this LearnSQL.com  PostgreSQL course! PostgreSQL is one of the most popular databases in the world. This is mainly due to its great functionality and the fact that it’s open source (i.e. free!). Postgres is fast, it runs on multiple systems, and it’s suitable for almost any application.

How to Use COUNT() with GROUP BY: 5 Practical Examples

Using the COUNT() function with GROUP BY is one of the most common SQL constructs in aggregate queries. Read this article to find out how to use COUNT() with GROUP BY correctly using 5 examples. In this article, we will explain the importance of using COUNT with GROUP BY. We’ll talk about why it is essential in SQL and how it enables data analysis and summarization based on specific criteria.

7 Reasons Why AI Won't Replace SQL Developers

So you've heard all about AI and the famous ChatGPT. And you're wondering if these tools would be beneficial or detrimental to your profession. In this article, we will put your fears to rest and explain how SQL and AI can work together and make developers’ jobs easier. Let's start with an explanation of what Artificial Intelligence (AI) is. AI is an area of computer science concerned with creating machines capable of performing activities that would normally need human intelligence.

What Is a LEFT OUTER JOIN in SQL? 4 Practical Examples

Today’s article will discuss the LEFT OUTER JOIN in SQL. We’ll go through several examples of LEFT OUTER JOIN usage and compare it with INNER JOIN. A JOIN is an SQL feature that allows you to combine data from two or more tables. The nature of relational databases makes JOIN one of the most commonly used features in SQL. Why? In practice, you’ll very seldom have all the required data in one table.

An Overview of MySQL Window Functions

MySQL window functions are very helpful when you want to create meaningful reports with SQL. In this article, we’ll demonstrate the most common window functions in MySQL and explain how to use them. MySQL 8.0 introduced a new feature: window functions. These functions are very useful to data analysts and anyone who creates reports using MySQL. Using them, you can easily compute moving averages, cumulative sums, and other calculations over specified subsets of your data.

Who Is a Data Manager?

Who are data managers? What are their responsibilities, and how do I become one? We’ll answer these questions and get you on your way to becoming a data manager! Simply put, data managers oversee the management of information or data within an organization. They manage data organization, storage, security, and accessibility, and they collaborate with other team members to guarantee data accuracy and usefulness in supporting decision-making. To ensure that data is effectively managed and used appropriately, they may also develop and implement policies and procedures pertaining to data management.

Boost Data Potential wht SQL and Python

In this article, we will explain why using SQL with Python is an awesome combination for unleashing the full potential of your data! Read on to find out how learning and starting to use the most popular programming language can have a positive impact on your work. You may be wondering why we write about Python on the LearnSQL.com blog? Well ... They are just a very good couple. Both languages are basic tools in such fields as data science and data visualization.

How to Use SUM() with OVER(PARTITION BY) in SQL

Discover real-world use cases of the SUM() function with OVER(PARTITION BY) clause. Learn the syntax and check out 5 different examples. We use SQL window functions to perform operations on groups of data. These operations include the mathematical functions SUM(), COUNT(), AVG(), and more. In this article, we will explain what SUM() with OVER(PARTITION BY) does in SQL. We’ll show you the most common use cases in real-world applications to determine the ratio of the individual row value to the total value, calculate running totals, and find a custom order total that includes discounts for certain products.

Course of the Month: INSERT, UPDATE, and DELETE in PostgreSQL

Do you want to be a data engineer or data analyst? Do you work with databases daily and need to expand your skills with the basics of data manipulation? You've come to the right place. For June 2023, our SQL course of the month is PostgreSQL INSERT, UPDATE, and DELETE Commands! Learn SQL for FREE! How do you get this free PostgreSQL course in June? Create a free LearnSQL.

Why Do You Need SQL to Work With Google BigQuery?

Data is just as important to your business as investing or accounting; that’s why many people use Google’s BigQuery data warehouse. In this article, we'll discuss why you should learn SQL if you want to start using BigQuery. Unleash the power of your data! In the ever-growing landscape of data-driven decisions, organizations are continuously on the lookout for tools that can help them handle and analyze their data efficiently. Enter Google BigQuery: a powerful, Cloud-based data warehouse designed to store and analyze massive datasets in record time.

How to Use SUM() with GROUP BY: A Guide with 8 Examples

Explore some real-world examples of using SUM() and GROUP BY in SQL, from the most basic to the most sophisticated. SUM() is a SQL aggregate function that computes the sum of the given values. GROUP BY is a SQL clause that partitions rows into groups and computes a stated aggregate function for each group. Using these two functions together, you can compute total sums for a group of rows. In this article, we’ll see 8 different examples of how you can combine SUM() and GROUP BY to create many different reports.

The Best Database Books You Should Read Now

So, you're interested in databases and looking for some database book recommendations. In this article, we’ll take a look at our top database book recommendations to feed your brain. In essence, databases are like digital filing cabinets. They have the ability to organize, store, and retrieve data. Large amounts of data are stored, managed, and made easily accessible by using databases. Additionally, databases make it possible for data to be organized into tables, which makes searching and sorting easier.

How to Learn SQL Without Any Programming Knowledge

If you think that learning SQL is only for programmers, you are deeply wrong. This skill is totally within your grasp! SQL is not just popular and in demand; it’s also quite easy and intuitive to learn. Read on to find out more! You’re searching for inspiration on how to start learning SQL. Maybe you want to change your job, or want to become more competitive in the job market.

The Most Important SQL Commands

In this article, we'll explore the most common SQL commands that everyone should know, including SELECT, INSERT, WHERE and more. We’ll also give examples of how to use each command. Are you ready to dive into the world of databases? SQL, or Structured Query Language, is a programming language that is designed specifically to interact with databases. It allows you to manipulate the data in databases in multiple ways – e.

Why Is Data a Valuable Resource for Your Business?

How do you build an effective data resource and make it work for you? In this article, I'll look at why data is so important to any organization and how to make the most of your data resources. Bad decisions are almost always based on incorrect or incomplete facts. Good decisions keep your organization competitive. In a nutshell, that’s why data is such an important business resource. Ever since the dawn of civilization, our ancestors have known the value of information.

Why SQL Is the Perfect Database Language

Which programming language should you learn if you want to work with databases? We’ll explain why SQL is the top choice! Learning a database language can be an incredibly valuable skill in today's data-driven world. But with so many options out there, it can be difficult to know where to start. In this article, we'll make a compelling case for why SQL is the ideal choice for anyone looking to dive into the world of databases.

How to Write Multiple Joins in One SQL Query

Have you ever wondered how multiple joins work? Want to know how to join multiple tables in one query? Read this article to find out! If you are just beginning your SQL journey, you may have found it difficult to understand the concept of SQL JOINs, especially if you have to join more than two tables in one query. Worry not! In this article, we will explore how JOIN works and solve all its mysteries!

Top 7 Advanced SQL Queries for Data Analysis

Explore essential advanced SQL queries for data analysis. Structured Query Language, or SQL, is an indispensable tool for data analysts. Most people pick up the language relatively quickly and can begin in-depth data analysis after just a few lessons. Because of this, many data analysts tend to stay in the beginner/intermediate level of using SQL. This level of understanding allows you to “get the job done”, but it might not be the most efficient way to write a query.

Free Course of the Month – GROUP BY Extensions in PostgreSQL

Do you work with data? Want to be able to create better and more sophisticated SQL reports? Then check out our interactive GROUP BY Extensions in PostgreSQL course. In May 2023, you can complete this online PostgreSQL course for FREE! How can you get this free SQL course in May 2023? Create a free LearnSQL.com account or log in if you already have one. Start the course.

MySQL Crash Course - An Interview With Rick Silva

If you've read my articles before, you probably already know that I love reading. What's more, I also collect SQL books. It may sound weird, but I enjoy comparing different approaches and ways of writing about databases. The best ones end up in our recommended books lists, like The Best SQL Books. One of those books, MySQL Crash Course, has just been released. I was able to talk to its author, Rick Silva, and this is what he told me.

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.

Learn SQL in 10 Minutes

Updated on: October 30th, 2023 Want to learn SQL fast? Our simple guide will teach you the essentials in just 10 minutes! Start querying data in no time. In today’s world, we use data for everything, and knowing SQL helps you understand this data better. Learning SQL means you can find and use important information in databases. Knowing SQL is an essential skill in any data-driven industry. For beginners, learning SQL is made easy with the right guide.

CTE vs. Subquery in SQL: What’s the Difference?

What are Common Table Expressions (CTEs)? Are they the same as subqueries? When would you need to use CTEs? This article looks at the similarities and differences between CTE vs subquery. When I introduce a student to Common Table Expressions, their first reaction is “That’s just a subquery! Why do I need to learn that?”. Let’s answer this question by looking at what you can do with an SQL subquery and what extra advantages there are in using a CTE.

10 Beginner SQL Practice Exercises With Solutions

Solve these ten SQL practice problems and test where you stand with your SQL knowledge! This article is all about SQL practice. It’s the best way to learn SQL. We show you ten SQL practice exercises where you need to apply essential SQL concepts. If you’re an SQL rookie, no need to worry – these examples are for beginners. Use them as a practice or a way to learn new SQL concepts.

How I Used SQL to Advance in My Career

Updated on: April 18, 2024 SQL has become increasingly valuable in today’s job market.  In this article, I will share my personal experience with SQL. I hope it will inspire you to grow in your career and achieve your own goals! A few years ago, I felt stuck in a job that I didn’t fully enjoy. Sure, there were aspects of my job that I appreciated, like building budgets, analyzing the performance of promotional programs, and watching my team grow professionally.

The Best SQL Blogs to Follow

In this article, you’ll find a list of the best SQL blogs and why they’re worth checking out. SQL (short for Structured Query Language) has been around since the 1970s. It’s still a wildly popular coding language. It is based on the idea that data can be structured and built through relations. If you’re familiar with SQL, you’ve likely heard the term “relational database.” This means that the tables of the database have pre-defined relationships between them: One field in one table will match another field in another table.

Best PostgreSQL Courses for Beginners

So you want to learn PostgreSQL but aren't sure how to get started? In this article, we look at some of the best online courses available on the Internet for learning PostgreSQL, so you can get started right away! What Is PostgreSQL? PostgreSQL is used in major companies such as Apple and Instagram. You may be wondering: should I learn PostgreSQL? PostgreSQL is a popular dialect of SQL, or Structured Query Language, a programming language for accessing and managing data in relational databases.

How to Learn SQL in a Week

Updated on: April 15, 2024 Need to learn SQL in a hurry? In this article, we’ll give you a learning path that will help you learn SQL in a week! So you want to learn SQL but don't know where to begin, how long it will take, or even if you have the time. In this article, we'll show you how you can learn SQL within a week using some resources that will get your SQL journey started in no time!

Free Course of the Month: SQL Reports in PostgreSQL

If you are looking for a course that takes your PostgreSQL skills to a completely different level, you've come to the right place. You can learn for free in April! We chose SQL Reporting in PostgreSQL for our Free SQL Course of the Month. It's just awesome – I'll tell you why. Do you want to be even better at SQL? Do you know the basics and want your SQL reports to be even more sophisticated?

How to Use CASE WHEN in GROUP BY

Learn how you can combine SQL CASE WHEN and GROUP BY to create custom categories in your SQL queries. Raw data, by its very nature, is not always human readable. Many times, the data you’re querying is in its most unformatted form. Examples of this include codes for different business departments or product SKUs that represent specific products. To the naked eye, these codes mean nothing, so pulling them into a report is not helpful for the person reading them.

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.

How to Practice Advanced SQL Online with LearnSQL.com

Want to go from intermediate to advanced SQL user? You’ll need to practice! Here are some ways you can practice advanced SQL online. You’ve seen how SQL helps you make data-driven decisions. Perhaps you’ve even learned some advanced features. But you’d like to become an expert—and for that, you need practice, practice, and more practice. Is it possible to get advanced SQL practice online? Taking SQL to the Next Level What is advanced SQL?

Best MySQL Courses for Beginners

SQL is among the most important languages when it comes to dealing with huge amounts of data. If your job includes analyzing or collecting data and you feel that an Excel file is not enough, you need to learn or develop your SQL skills. And if you learn SQL, you also need to know one of its most popular dialects - MySQL. If you've made the decision to learn SQL, you've come to the right place.

The SQL COUNT() Function: A Detailed Guide

Updated on: April 22, 2024 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.

Learning SQL in Your Native Language is Finally Possible

Updated on: April 21, 2024 Do you or someone you know speak English as a second language? Would you like to learn SQL online in your preferred language? Good news! Our awesome SQL courses are now available in French, Spanish, German, Italian, and Portuguese! SQL, or Structured Query Language, is a programming language used for managing and manipulating data in databases. It's an essential skill for anyone working with data, whether you're a data analyst, a software developer, or just someone who wants to understand how databases work.

The Best Apps to Learn SQL

Updated on: April 23, 2024 Let us guide you to the best apps for learning SQL on the go. They are designed to seamlessly integrate into your busy lifestyle – ensuring you develop your database skills anytime, anywhere. Are you eager to dive into SQL but unsure where to start? This article is your ultimate guide to the top apps for learning SQL. We include suggestions tailored for users of all levels, from beginners to advanced learners.

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.

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.

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.

How to Concatenate Two Columns in SQL – A Detailed Guide

In SQL, concatenation is the operation of joining together strings, or pieces of text information. Learn how to concatenate two columns in SQL with this detailed guide. SQL concatenation is the process of combining two or more character strings, columns, or expressions into a single string. For example, the concatenation of 'Kate', ' ', and 'Smith' gives us 'Kate Smith'. Enhance your SQL skills with our interactive SQL Practice Set!

Data Cleaning in SQL

Data cleaning is an important part of any data analysis. Here we’ll discuss techniques you can use to do data cleaning in SQL. I find it nearly impossible to focus on work when my desk is a mess. If it’s cluttered with paper, coffee mugs, or random toys my daughter has somehow snuck into my office, there is no chance I will be able to get anything done until my desk is back in order.

Learn SQL for Data Analysis with LearnSQL.com

Updated on: December 1, 2023 Discover how to learn SQL for data analysis and start making sense of your data today. Our guide provides a clear and simple SQL learning path for data analysts, helping you query databases and analyze data with ease. Whether you're starting from scratch or looking to polish your skills, we'll help you every step of the way. When I was in high school, I planned to go to college and major in interior design.

Top SQL Certificates in 2023

SQL is an essential skill in today’s data-driven world. Looking for the best SQL certificates to further your career can be confusing. This article gives some pointers that will help you make the best choice to fit your goals. Who needs an SQL certificate? If you can write advanced SQL queries, surely you can just demonstrate your skills at the interview and you'll be hired. Yes ... but ... you won't reach the interview unless the recruiter invites you.

Free Course of the Month – PostgreSQL JOINs

Our PostgreSQL JOINs course will help you consolidate your knowledge of working with data from two or more tables in a PostgreSQL database. Throughout the month of February 2023, this awesome SQL course is absolutely FREE! Wondering why we want to give you this SQL course for free? We've been doing this for a long time. Every month, we choose one of our interactive online SQL courses and give users free access to it.

Introducing Our New Ultimate SQL Cheat Sheet!

Do you ever find yourself writing an SQL query and forgetting the syntax of some function? That sometimes happens to me too. Fortunately, LearnSQL.com has prepared this awesome Ultimate SQL Cheat Sheet you can always have on hand. Print it or save it to your browser's favorites and make your data querying more efficient! If you are looking for an SQL Cheat Sheet, it is safe to assume that you already know what SQL is.

How to Group by Multiple Columns in SQL

When analyzing large data sets, you often create groupings and apply aggregate functions to find totals or averages. In these cases, using the GROUP BY clause with multiple columns unfolds its full potential. GROUP BY is a clause of the SELECT command. It allows you to compute various statistics for a group of rows. For example, you can use GROUP BY with an employee table to know how many employees are of each gender.

SQL for the Business Analyst

How can SQL benefit business analysts? In this article, we’ll discuss why SQL is a fundamental skill in this role. You’ll also learn what a business analyst does and what they need to advance their career. According to BrainStation, the already high demand for business analysts is set to grow even more. One of the driving forces behind the rising demand is the digital revolution, which has been accelerated by the recent pandemic.

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.

Is SQL Hard to Learn?

If you have no IT skills, how hard is it to learn SQL? Will it be too technical for you? Is it worth the effort? And where would you start? In this  article I will answer those questions. As an IT consultant and trainer, I've often advised people to learn SQL. And, almost as often the reply has been, "Is it hard to learn SQL? Do I need technical or IT skills to learn it?

Database Jobs to Choose in 2023

In this article, we will explore some of the top database jobs to choose from in 2023. So you want to land yourself a database job in 2023. It’s a great choice, and there are lots of options. Let’s talk about the most popular data-related jobs and what you need to do to get one. SQL Is Essential for a Database Job It’s important to mention that most of the popular databases nowadays are relational – i.

UNION and UNION ALL in SQL Explained

In this article, we’ll explore the SQL clauses UNION and UNION ALL. Learn what they do and when to use each one. I had been an analyst for probably four years before I knew about the SQL clause UNION ALL. I used UNION on a regular basis, but had never heard of its counterpart. Then one day when I heard a coworker talking about it. I thought to myself, “What is he talking about?

SQL Books for Beginners

How can you learn SQL more efficiently? Besides a good online course, find an interesting book to enrich your knowledge. Here are the best SQL books for beginners. SQL, or Structured Query Language, is a very powerful tool to work with many types of data. If you are interested in learning SQL you probably know how useful it is, and how widely it is needed. To learn SQL successfully, a solid online course for beginners like our SQL Basics is a great start.

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.

Learn Advanced SQL with LearnSQL.com

In this article, we will propose a learning path that will cover advanced SQL topics. If you already know the basics of SQL, you probably have figured out that most online and offline SQL tutorials and courses usually cover the basic and intermediate concepts: SELECT, FROM, WHERE, ORDER BY, GROUP BY, and joining tables. Even university database courses typically don’t cover more advanced  SQL topics. While this is enough SQL for most everyday tasks, there are some relatively new features that have been added to SQL in the last 20 years: window functions, recursive queries, and GROUP BY extensions (ROLLUP, CUBE, GROUPING SET).

What Are DDL, DML, DQL, and DCL in SQL?

We explore the separation of SQL into its four principal sublanguages and explain the meaning behind each of them. When you’re learning SQL – perhaps through LearnSQL.com’s very own comprehensive SQL Basics course – you may have come across the terms DDL, DML, DQL, and DCL. And maybe you’ve gotten confused by all the acronyms. In this article, we will explain what these terms stand for and how they correspond to sublanguages that neatly divide the SQL language into four parts that function together.

How to Use WHERE with GROUP BY in SQL

In this article, we’ll discuss how to combine the WHERE and GROUP BY clauses in SQL. If you’re writing SQL on a daily basis, you will quickly realize how often both WHERE and GROUP BY clauses are used. WHERE is an essential part of most queries. It allows you to filter large datasets to only the pieces you are interested in. GROUP BY is one of the most powerful tools an analyst has when aggregating data.

Want to Get a Data Engineering Job? Learn SQL!

So, you want to be a data engineer, but you don't know how to get there. In this article, we’ll help you understand the skills you'll need for different types of data engineering jobs. You’ll also find some data confirming that data engineer jobs are a good career choice. Data engineering and various types of data engineer jobs have become very popular in recent years. And for good reason: Next to data science, data engineering is one of the fastest-growing branches of IT.

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).

How to Export Data From Microsoft SQL Server to a CSV File

When working with data and databases, it is common to export data for further processing or transport to another database. Follow this article to learn how to export data from Microsoft SQL Server to a CSV file. In this article, we first recall what a CSV file is and why you would want to export data in this format from an MS SQL Server database. Then, we cut to the chase and export data to a CSV file using both SQL Server Management Studio (SSMS) and SQL Command Line (SQLCMD).

The Future of SQL

Is it worthwhile to learn SQL? Or will a language that’s over 40 years old soon be outdated? Have relational databases been eclipsed by the advent of other database solutions like NoSQL? In this article, we answer these questions. Do you need to upgrade your IT skills? What should you learn first? The choice is daunting. If you're looking to the future, you obviously want to invest your time in something that's still widely used and will continue to be in the years to come.

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.

The Most Popular Databases in 2024

Updated on: April 6, 2024 If you work with data – or if you want to start – you need a database that will answer your needs. Not sure what to choose? Don’t worry! In this article, you’ll find a list of today’s most popular and efficient databases, with a quick summary of what each one does. Businesses run on data. But to get the most from that data, it needs to be stored in a structured way – usually in a database.

How to Export Data from MySQL into a CSV File

A database is a primary platform for working with data and storing data. But often, you must take your data out of the database. Read on to find out how to export data from MySQL database into a CSV file. In this article, we’ll demonstrate how to export data into a CSV file. We’ll start by introducing what a CSV file is and why we use it. Then, we’ll export data from a MySQL database into a CSV file.

I’m a Software Developer. How Do I Learn SQL?

What do you need to know about relational databases and SQL as a software developer? In this article, we’ll explain the topics you need to know and how you can acquire this knowledge. If you are a software developer, you may have noticed that SQL skills are often required in some development roles. Although you are not a database manager or a data scientist, you will need solid SQL foundations to continue your developer journey.

What Is an SQL Database?

SQL databases have been used for decades and have grown in popularity, becoming one of the most common data management tools. They provide the user with an efficient way to store the data and an intuitive way to access or modify it. In this article, we’ll start by explaining what a database is and showing some examples. We’ll move on to how databases can be used to efficiently work with large amounts of structured data.

Top 6 Online SQL Courses for Beginners in 2024

Updated on: November 20th, 2023 Whether you’re dreaming of a career in data analytics or just want to learn a new skill, learning SQL is worthwhile. But don’t waste your time on poorly-designed courses or other learning resources! In this article, I’ve collected the best online SQL courses for beginners. Pick one and start being awesome! SQL (Structured Query Language) has emerged as one of the top skills that recruiters look for when it comes to data related jobs.

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.

How to Use the PARTITION BY Clause in SQL

We’ll be dealing with the window functions today. Specifically, we’ll focus on the PARTITION BY clause and explain what it does. PARTITION BY is one of the clauses used in window functions. In SQL, window functions are used for organizing data into groups and calculating statistics for them. It sounds awfully familiar, doesn’t it? Even though they sound similar, window functions and GROUP BY are not the same; window functions are more like GROUP BY on steroids.

SQL Track of the Season: SQL from A to Z in MS SQL Server

Maybe your company uses MS SQL Server and you’d like to join the data analysis team. Or maybe you want to add a new skill to your CV. Either way, our SQL Track of the Season: SQL from A to Z in MS SQL Server, will help. In this article, I’ll answer common questions about this awesome set of online MS SQL Server courses. If you’re reading this blog post, you probably already know that you should start learning SQL and working with databases.

What Are the Basic SQL Queries?

You can access the data in a database using some basic SQL queries. In this article, we review the fundamentals SQL queries every beginner should know. Databases are everywhere, and they contain different kinds of data. Almost all of them support SQL, a language that lets you read and manipulate the data inside a database. In this article, I’ll show you the basic SQL queries that you can use to perform many common everyday data tasks.

An Overview of SQL Text Functions in PostgreSQL

If you’re a PostgreSQL user and into data analysis, you’ve heard of the text functions or maybe even used them. But what are PostgreSQL’s most popular text functions? In today’s article, we’ll show you what they are and how to use them. As anyone who works with them knows, databases don’t contain only numerical values. Among other data types, databases also store text or string data. To use PostgreSQL effectively, you’ll have to know at least some of Postgres’ text functions.

What Does a Double Colon Operator in PostgreSQL Do?

The double colon operator :: in PostgreSQL is a synonym for CAST, which converts a value into a different data type.  If you are curious about the details , read on! Have you ever seen a double colon (::) operator in someone’s PostgreSQL code? It would look something like this: SELECT '2022-09-02'::date; This code converts the text '2022-09-02' to a date datatype. As mentioned above, the double colon replaces the CAST operator.

SQL Beginners: Questions to Ask Before Writing a Query

SQL is known for its easy-to-follow syntax that even beginners can understand pretty quickly. Still, to write your own SQL queries, you need to know the basics. Let’s explore what things need to be considered before writing a SQL query. If you are looking for a career in data analysis or just want to work effectively and independently with data in any analytical position, you’ll need to master SQL. Luckily, this programming language is beginner-friendly and can be learned just in a few months with the right learning sources.

Why You Need Analytical Skills to Get Promoted at Work

Do you wonder if analytical skills might benefit you in your job? Are ‘analytical skills’ the same as data analytics? Is SQL a useful analytical skill? Read the article to answer these questions. Analytical skills allow you to better understand problems in your work; good analytical skills bring many benefits to your career. The term ‘analytical’ refers to a wide range of traits and capabilities, making it sometimes ironically vague and general.

SQL Courses for Software Testers

In this article, you will learn why software testers need SQL and which courses are ideal for them to learn it. Do software testers need SQL? Oh yes, they do! They don’t necessarily use it all the time or take advantage of all its possible features. But a tool for accessing data in a database is essential for a software tester. And SQL is exactly that: a programming language designed specifically for handling data in relational databases.

How Much Do Business Analysts Earn?

What does a business analyst do, and why are they essential to their companies’ success? What skills do you need to become a business analyst? How much can you expect to earn? We’ll answer all those questions in this article. With our dependence on digital systems increasing by the day, IT and IT related jobs like business analysts are seeing a continuous boom in opportunities. Did you know that IDC estimates around 60% of the global GDP will be mostly impacted by the introduction of digital tools by the end 2022?

How the WITH Clause Works in SQL

Do you want to master complex SQL queries? Learn how to use the powerful WITH clause! In SQL, there are simple queries and complex queries. A simple query can take data from a table, apply a filter, and return the data as it is in the source table. A complex query may require complex transformations to the source data or may need to read and join data from multiple tables or views.

SQL ORDER BY Clause with 7 Examples

Get to know the SQL ORDER BY clause! Our practical and easy examples will help you understand its syntax, common uses, and best practices. SQL or Structured Query Language lets you “talk” to a database. It enables you to create, retrieve and manipulate the data in a relational database. This language has become so ubiquitous that hardly any data-related field has been untouched by it. If you’re interested in the SQL ORDER BY clause, I’m assuming you have either already started learning SQL or are planning to start it soon.

Roadmap to Becoming a Data Analyst

What is a data analyst? What are their daily duties, and what skills do they need? In this article, I discuss the role of data analysts and share a step-by-step guide on how to become one. As organizations start to realize the value of their data on their customers, target audience, competitors, suppliers, and other market players, the role of data analysts becomes more important. To become a successful data analyst who can bring real value to the organization, you need to possess a specific set of skills.

How to Import a CSV File to a MySQL Database

CSV files store and transfer data between databases. Read on to find out how easy it is to work with CSV files in a MySQL database. CSV files are one of the oldest data exchange formats and are still heavily used by IT professionals from various domains. It is common for online data resources and different database software to offer their data uploads and downloads in CSV format. In this article, we’ll briefly review what a CSV file is and how to work with it.

SQL Syntax

In today’s article, we’ll give you a walkthrough of core SQL syntax with a focus on the SELECT, INSERT INTO, UPDATE, and DELETE statements. SQL is a programming language designed specifically to communicate with databases. It allows you to get the data from a database or change the data within it. Like any programming language, SQL has a syntax you must adhere to. In other words, there are rules to follow regarding its commands if you want your code to work.

Learn SQL for Data Science With LearnSQL.com

If you are interested in a data science career and have looked at a few relevant job descriptions, you've probably noticed many leading tech companies expect their data scientists to know SQL. Let's see how you can learn SQL for data science and become more valuable to any data-driven organization. A data scientist is a complex technical role that expects a combination of the skills of a statistician, a business analyst, and an IT expert.

How to Learn SQL for Marketing Analytics With LearnSQL.com

SQL is a valuable tool for any experts wanting to make data-driven decisions. Marketers are no exception. Let's explore how to design an effective learning path for SQL in marketing. SQL for marketing analytics is used to understand customers better and to increase the effectiveness of marketing campaigns. If you work in marketing and want to join other marketing experts who have already benefited from this tool, you need to learn SQL.

What's New in MS SQL Server 2022

Microsoft SQL Server 2022 is almost here! In this article, we’ll review what new enhancements and features will be coming to this popular relational database. The new version of MS SQL Server will become available almost three years after SQL Server 2019 was released. (You can learn more about the origins and different versions of SQL Server in A Brief History of MS SQL Server.) If you need to start implementing a software solution, there are plenty of changes and new features in SQL Server 2022 that makes it a great option.

How to Learn SQL

It takes quite an effort to learn SQL or any new skill for that matter. But pushing hard is not enough to learn it successfully. You can sit for hours and still feel like you're not making progress. So, what do you do? Let it go or try even harder? I say: work smart, not hard. SQL (Structured Query Language) is one of the most popular programming languages. It is an invaluable tool in a world overflowing with data.

Summer 2022 Track of the Season: Creating Database Structure

Summer is a great time to learn something new! Have you heard about data engineering? It’s one of today’s hottest skills. In this article, I'll show you why we selected our Creating Database Structures track as our SQL Track of the Season – and why it’s your ticket to a new career! LearnSQL.com offers online SQL training tracks – logically structured and well-thought-out learning paths that will help you work towards becoming an SQL expert.

An Overview of SQL Text Functions in Google BigQuery

Data analysts and Google BigQuery go hand in hand. Google's cloud data warehouse presents you with plenty of opportunities for using standard SQL text functions you can't avoid in your day-to-day work as a data analyst. BigQuery uses Google Standard SQL, an ANSI-compliant SQL dialect. This means you can use standard SQL text functions in BigQuery without needing to learn a variant of a given function. The Standard SQL Functions course is an excellent resource for learning those functions.

PostgreSQL vs. MySQL: Is It Difficult to Switch?

So you know PostgreSQL, but the boss has decided to switch to MySQL. What are the differences between these two SQL dialects? We discuss PostgreSQL vs. MySQL in this article. PostgreSQL has gained popularity in the last decade, and many developers and database specialists learned PostgreSQL as their first SQL dialect. But PostgreSQL is not the only relational database; during your IT career, you will probably be asked to use another SQL dialect – like MySQL.

How to Use Aggregate Functions in WHERE Clause

Filtering data according to the result of an aggregate function is a common data analysis task. So how do you use aggregates in the  WHERE clause? We’ll dedicate this whole article to answering that question.   Combining aggregate functions and filtering based on their results is often used in data analysis – e.g. showing branches with total sales above X,  countries where the number of posts is lower than Y, students with an average score below Z, and so on.

What Is an SQL Query?

An SQL query is the most basic SQL command. It is a question you ask a database. In this article, we dive into the basics of SQL queries to kickstart your SQL journey with practical knowledge right away! SQL, or Structured Query Language, is a programming language designed to interact with databases. When you want to access data in a database, be it to alter, delete, add, or simply extract information, you use SQL.

Lesser-Known SQL YouTube Channels You Need to Follow Now!

Are you learning SQL? Many beginners start with YouTube tutorials. However, popular SQL clips are not always very helpful. You need to know which ones to watch so that you don't waste your time. In this article, I discuss SQL YouTube channels that, while not the most popular, deserve your attention. Click "subscribe" and watch! Those who follow my articles on LearnSQL.com know I'm not a huge fan of learning SQL from YouTube.

How to Set Up a Corporate SQL Training Program

Are you looking to set up a business or corporate SQL training for your company's employees? In this article, we’ll discuss how to build an efficient SQL training program and why the LearnSQL.com platform is the choice of leading tech companies. If you are responsible for employees’ professional development – especially in a data-driven company – you know that SQL is essential for anyone who works with data. This programming language can enhance the performance of data and business analysts (for whom SQL is often a primary tool) as well as marketers, salespeople, HR specialists, auditors, and many more.

How to Get More from Your BI Tools with SQL

Are you frustrated with the limitations of your business analytics tool? Do you wonder if there are other features you could tap into? Would you like to know how SQL compliments your work with Power BI and Tableau? Read this article to learn more! If you are a data analyst or if data analysis is part of your everyday job, Business Intelligence (BI) tools are crucial for your work. You also know that most databases run SQL queries in the background of such tools.

Use SQL for Data Analysis With the New Google Analytics 4

As Google is sunsetting its Universal Analytics in favor of Google Analytics 4, data analysts need to adapt and learn how to get the most from the new tool. In this article, I'll discuss how to enhance your data analysis by using SQL with Google Analytics 4. Universal Analytics by Google has been helping data analysts and marketers in all industries everywhere understand their audience better. However, Google recently announced they would stop their support of Universal Analytics on July 1, 2023.

Switching from PostgreSQL to MS SQL Server

What are the differences in PostgreSQL vs. MS SQL Server? We discuss the similarities and the differences between these two popular SQL dialects. Many of us developers and database specialists began working with free relational databases like PostgreSQL or MySQL for personal projects or small organizations. Some of us have since moved on to organizations using MS SQL Server and have had to learn to use the new tool. You may be wondering how challenging that is and whether you would struggle with SQL Server under similar circumstances.

5 Tips for Learning SQL for Beginners

Being data-driven is a hot trend right now. Employers are looking for people who can work with databases. This is why you should learn SQL. In this article, I'll explain how to go about doing so. Yes, learning SQL may be the right thing for you even if you have never seen a line of code. As with any new skill, it requires the right approach and the right resources.

What Is SQL Used For?

So you’ve heard about databases and SQL, but you’re not sure what the big deal is. Read on to find out why data skills like SQL are so important. It seems like every other job requires you to know something about data, databases, and SQL. But what are these things, and what are they used for? Who even uses SQL? That’s what we’ll discuss in this article. Why Data Is So Important The Internet and the technology revolution have brought unprecedented opportunities.

An Overview of SQL Text Functions in MySQL

Do you work in MySQL as a data analyst? Then you should know how to use its text functions – data analysts don’t work only with numbers. Reporting requires computations, data classification, and label creation, and you can do all of that in MySQL.  In this article, I’ll explain several of the most common and useful MySQL text functions by discussing what they do and showing how they do it.

Learn the OVER() Clause in SQL with 7 Examples

Learn how to use the OVER() clause in your SQL queries and you will take a step forward in your SQL knowledge. Most data analysts and SQL developers have a good handle on the SELECT, FROM, WHERE, GROUP BY, and ORDER BY clauses. However, these clauses are only a limited subset of the SQL language. There are other clauses, such as OVER(), which allow us to create flexible SQL reports and add an enormous expressive power to the SQL language.

What Is SQL?

SQL may be something you hear about from your colleagues. Or you may see it in the job description for your dream role or notice it in a list of the most popular programming languages. So, what is SQL? Should you learn it? Let's find out. Do you think about a career in data analysis and data science? Do you need to interact with relational databases at work? Do you want to improve your performance as a marketer, HR specialist, or researcher by making more informed decisions?

Prepare for a SQL Interview with LearnSQL.com

You've been working hard to get a SQL interview at your dream company. Now they’ve called – and you need to prepare if you’re going to ace it. In this article, I’ll show you the most efficient way to prepare for a job interview using the interactive SQL courses at LearnSQL.com. SQL is an essential skill for anyone working with data. Wanna be a data analyst, data scientist, software engineer, or tester?

Learn SQL in 4 Steps

Want to work with data? You’ll need SQL. Fortunately, you can learn SQL in just 4 steps! If you are interested in data crunching or working with data in general, you’ve probably heard something about SQL. Now that data storage is cheap and accessible, data from every transaction can be stored and analyzed. Hence, there’s great demand for people who can capture and work with this data. We’ve even seen entire companies profit from being proficient with data; for example, consider the ever-growing value of Google and Facebook (now Meta).

These SQL Queries Will Help You With Data Analysis

Need to streamline your everyday data analysis tasks? This article explains how basic SQL queries can help. If you are planning a corporate career or any field that involves working with data, you must have come across SQL, or Structured Query Language. SQL was first developed in the 1970s and it continues to be the industry standard for database interactions. Many of you may already have decided to learn this language, given how powerful it is.

5 Tips for You From a Senior SQL Data Analyst

Are you looking for tips for becoming a better data analyst? Do you want to know about the mistakes and issues you may face? I have collected five tips for your everyday work based on my experience as a data analyst. You may have already read about what data analysts do, how much they earn, and how to become one. However, there is more to it than just becoming a data analyst.

How to Combine Two Aggregate Functions in SQL

Having trouble using two aggregate functions in one query? This article will show you how to do it the right way – actually, the two right ways. In data analysis and reporting, we often need to count the number of records or sum them up and then calculate the average of this count or sum. Translated to SQL logic, this is the aggregation of aggregated data, or multi-level aggregation. For aggregation purposes, there are the SQL aggregate functions.

Free SQL Course of the Month – PostGIS

What is PostGIS, and why should you learn it? (Hint: Our SQL PostGIS course is free throughout June 2022!) Did you know databases can store geographic data? This is how interactive maps are made, most often based on PostGIS. In this article, I will tell you what PostGIS is and why it’s worth learning. Moreover, I am going to offer you an awesome online PostGIS SQL course which you can do for free during June 2022!

How to Install a MySQL Database on a Windows PC

Do you want to install a MySQL database on your Windows computer? And maybe find out how to start using a MySQL database? In this article, we’ll cover the installation process. MySQL is one of the most popular relational database servers. This is one reason to start using a MySQL database. Among the various editions of MySQL delivered by Oracle, the Community edition is available for free. You can download it from the MySQL website.

Over 40 and Want to Upskill? Learn SQL!

You have several years of experience. Your work has even been written up in a few case studies. Yet, you still have a hard time finding the right path to improve your career. If that's true for you, the answer is to learn SQL. In this article, I'll tell you why. Why learn SQL when you’re already an experienced professional? It’s always good to learn something new. You may want to pick up a new hobby, try out a different industry, or get a new skill to help your career.

How to Use the COALESCE() Function in SQL

SQL users are often faced with NULL values in their queries and need to process them properly. The COALESCE() function helps handle NULL values. Read this article to learn how to use COALESCE() in your queries. SQL tables store data in records, and records are composed of fields. There can be situations where we don’t know the value for a specific field. For example, let’s suppose we have a table with data for persons.

The Recent Rise of DBT and the Analytics Engineer

If you’re interested in data engineering or data analytics, you should know about DBT. And you should also learn about the role of an analytics engineer. We cover both in this article. The rise of Cloud data providers has led to new challenges and possibilities. If you are thinking about entering the data analytics space, it is important to be aware of them; it can help you decide what roles to aim for and what skills to learn.

Top 9 SQL GROUP BY Interview Questions

Preparing for an SQL job interview? This guide will walk you through nine basic, intermediate, and advanced GROUP BY questions that you may have to answer. There are common GROUP BY questions that pop up in a lot of SQL job interviews; in this article, we’ll explain how to answer them. If you are a data analyst or another data professional preparing for an interview, this article aims to help you out.

What Are Window Functions in SQL?

In this article, we discuss what window functions are and how they help you do your job as a data analyst or specialist. No, window functions have nothing to do with the operating system. The window here refers to a set of rows over which the function aggregates data. To learn how window functions work, what functions there are, and how to apply them to real-world problems, it’s best to take the Window Functions course.

The Complete Guide to the SQL WHERE Clause

Learn how to use the SQL WHERE clause to filter rows. In this comprehensive article, we cover comparison operators and the BETWEEN, IN, LIKE, AND, OR, and NOT operators. Filtering output rows is one of the first things you need to learn when starting your SQL journey. In this guide, we’ll see how to use the SQL WHERE clause to filter rows in different scenarios. We’ll cover basic and some more advanced use cases.

Why Should Every Data Analyst Know SQL?

In the 1980s and 90s, it was the emergence of ERPs, processing a few thousand transactions a day. Now, sophisticated Cloud-based systems work with billions of transactions each day. How data is captured and handled has come a long way! Anybody who understands how to use this data has an edge. The good thing is that while the technology working in the background has become more complex, we don’t necessarily need to understand the underlying system’s details to use it.

How to Update Only the First 10 Rows in SQL

Real-world databases require continuous updating. Often, you need to update specific records; you may even want to update only the first row, or the first 10, 100, or 1000 rows. Let’s explore how to update rows for a specified quantity from the top in SQL. What Is the SQL UPDATE? In SQL, an UPDATE statement modifies existing records of a table. You may choose to update entire columns or update rows filtered with a WHERE statement.

Top 5 MySQL Query Tools

Are you looking for a software solution that will make working with the MySQL database even easier? In this article, I’ll tell you about five highly recommended query tools that will save you time. MySQL may already be familiar to you as the most popular open-source relational database management system (DBMS). It works in most applications, which is why the last Stack Overflow report rated MySQL as the most used database.

The SQL Syntax Is Simple: True or False?

Updated on: April 19, 2024 Are you contemplating learning SQL but are concerned about how difficult it may be, especially if you have no prior coding experience? If so, you are not alone. In this article, I show you how simple the syntax of SQL is and that it is worth your time to learn it. You just need to know how to approach it properly. Many people carry the notion that learning SQL is much like learning other programming languages.

What Are the Different SQL JOIN Types?

You just can’t understate the importance of the JOIN when learning SQL. Not only is it one of the most fundamental operations in relational databases, but it is also very versatile with many different types. Although SQL JOIN may be intimidating at first, it becomes a very handy instrument in your arsenal once you understand it. Let’s explore all the SQL JOIN types! We can safely say the JOIN operation is one of the most powerful features of SQL.

How to Use the ROUND() Function in SQL

Need to round numeric results in SQL? The ROUND() function is here to do the job. Modern relational databases offer many built-in functions that extend the capabilities of SQL. In this article, we will use practical examples to explain how the ROUND() function works. (Spoiler alert: If you guessed that it rounds a number to a certain decimal place, you’re right! Read on to find out more.) SQL Standard Functions Each SQL database (PostgreSQL, MySQL, Oracle, SQL Server among others) has a set of built-in functions.

How to Write Multiple CTEs in SQL

Leverage the full potential of the CTE by combining two or more of them in a single SQL query. Common table expressions, or CTEs, can be a powerful SQL tool. When you write two (or even more) CTEs together, this power multiplies. In this article, I’ll show you three ways of writing multiple CTEs: Using two independent CTEs in one SQL query. Using two CTEs where the second CTE refers to the first.

The SQL Substring Function in 5 Examples

Working with text data in SQL? We explain how to get values from any point in a string. When you think of working with data in SQL, your first thought is probably a database full of numbers and your SQL code doing very fancy calculations. But text is data, too! It’s very common to find text data in databases. Not only do you have to extract it, but often you also have to manipulate it.

Are You Ready to Become a Data Analyst?

Data analysts enjoy strong career prospects. Do you have the skills required for this role? Let’s find out! If you enjoy working with data, searching for interesting patterns and valuable insights, you may wonder “Should I become a data analyst?” In this article, I’ll explain what data analysts do and what skills a successful data analyst needs. What Does a Data Analyst Do? Data-driven organizations rely on specialists who know how to get value out of data.

SQL and Cloud Databases Are the Perfect Match!

Do you want to do analytics in the cloud? Are you considering learning SQL and wondering whether you can use it with cloud-based databases? Do you want to know how cloud databases and SQL work together? We answer your questions in this article. Read on! You may be an analyst who has heard about cloud databases and SQL and want to learn more. Maybe you are already familiar with them and want to know if the two technologies fit together.

These Are the Websites You Should Know When Learning SQL

Updated on: April 6, 2024 If you're diving into SQL and searching for top-notch resources to enhance your learning, you've arrived at the right article. Discover the ultimate SQL learning websites that we’ve carefully chosen to support your educational journey. Today, I'm going to share a list of websites that will help you with learning SQL. You will find useful resources, get introduced to some fantastic communities, and expand your database knowledge.

New MySQL Courses Are Here!

A lot of you have been waiting for new MySQL courses on LearnSQL.com – and finally, they’re here! Now you can learn everything MySQL in a simple, understandable, and fun way. We've worked a lot with these online SQL courses and created hundreds of interactive exercises to help you learn this popular SQL dialect. If you want to communicate with the world’s most popular open-source database, our MySQL courses will help you achieve that goal!

LearnSQL.com’s Monthly SQL Practice in 2022

Are you looking for ways to practice SQL? Tired of boring exercises based on unreal scenarios? We have something for you! Every month, we publish a new set of SQL practice exercises. You'll find all of them in the monthly SQL Practice. Here at LearnSQL.com, we believe the best way to learn SQL is through practice. All of our SQL courses (and there are over 30 of them!) are hands-on.

An Overview of MySQL Data Types

What data types are available in a MySQL database? In this article, you’ll learn about numeric data types, text data types, and much more! You may have seen our article about data types in SQL. Here, we focus on the MySQL data types. We will discuss the most commonly used ones: numeric, text, and date and time. If you are interested in the topic, be sure to check out our Data Types in SQL course.

How to Keep Unmatched Rows From Two Tables in a SQL JOIN

Are you looking to join two tables in SQL without removing unmatched rows? Do you want to keep unmatched rows from one or both tables? In this article, I’ll explain how to keep all the records you want by using outer JOINs, such as LEFT JOIN, RIGHT JOIN, and FULL JOIN. Examples included! The SQL JOIN is a powerful tool that helps you combine data from multiple tables of your database.

How to Query a Parent-Child Tree in SQL

What are parent-child tree structures in SQL? In this article, we answer that question, talk about query hierarchy, and demonstrate the five most common SQL queries you’ll need for these data structures. Yes, you can use SQL on a parent-child tree structure. I’ll show you how in this article. Along the way, I’ll walk you through five query examples, starting with the easiest and ending with the most complex.

What Is the Future of the Data Engineer?

If you are wondering about the future of data engineering as a career and whether it is worth becoming a data engineer, then this article is for you. Here, I cover how lucrative the prospects are for data engineering and how you can get started and thrive in the domain. “Data” is probably one of the most used terms in our everyday business language today. A data engineer plays a pivotal role in developing the infrastructure required for data-related actions.

Is Learning PostgreSQL in 2022 Worthwhile?

You want to take a SQL course, but selecting the right one can be too challenging. Perhaps you don't know which dialect you should start with? PostgreSQL is one of the best options. Check out if it is worth it to learn PostgreSQL in 2022. When you search the web, there are many job advertisements for database specialists. Perhaps that is why you have chosen the direction toward development. Or maybe you are just fed up with Excel in your day-to-day duties (which is not surprising) and want to make work easier.

How Do You Get Rid of Duplicates in an SQL JOIN?

Do you have unwanted duplicates from your SQL JOIN query? In this article, I’ll discuss the possible reasons for getting duplicates after joining tables in SQL and show how to fix a query depending on the reason behind the duplicates. Data analysts with little experience in SQL JOINs often encounter unwanted duplicates in the result set. It’s challenging for beginners to identify the reason behind these duplicates in JOINs.

The SQL OVER() Clause Explained

Here is a detailed explanation of the OVER() clause in SQL window functions. This is a detailed guide on using the OVER() clause in SQL window functions. I will focus specifically on this clause, which requires that you have at least a general idea of how window functions work. To make the best out of this article, take a look at the SQL Window Functions Cheat Sheet. Feel free to have it by your side as we go.

PostgreSQL Interview Questions and Answers

Job interviews are always stressful. Interviewing and getting asked technical questions about PostgreSQL is even more of a challenge! In this article, we’ll cover some of the PostgreSQL interview questions you can expect when applying for a new job. By the end of the article, you should be able to handle most of the questions you are likely to face. We’ve previously covered common questions you can expect at a SQL job interview, but this article will be focused on Postgres specifically.

What Is a Common Table Expression (CTE) in SQL?

The common table expression (CTE) is a powerful construct in SQL that helps simplify a query. CTEs work as virtual tables (with records and columns), created during the execution of a query, used by the query, and eliminated after query execution. CTEs often act as a bridge to transform the data in source tables to the format expected by the query. A common table expression, or CTE, is a temporary named result set created from a simple SELECT statement that can be used in a subsequent SELECT statement.

The Top 5 SQL Courses and Learning Platforms for 2022

It’s the New Year! Time to start thinking what good you can do yourself in 2022. If you haven’t decided yet, we want to recommend learning something new – specifically, learning SQL. Maybe learning SQL is already on your 2022 to-do list. If so, take it seriously – learning SQL can change your career path and even your life! It makes sense to find the best SQL courses so you can learn effectively.

Top 10 Beginner Online SQL Courses in 2022

Ready for New Year’s changes? Good, because now you have a perfect chance to achieve something new: Improve your skills by learning SQL! In this article, we’ll point you toward some great online SQL courses to help you meet this goal. SQL, or Structured Query Language, is the language used to communicate with relational databases. When you know SQL, you can add, delete, change, and make calculations using the data in a database.

The Most Popular Databases for 2022

With the number of database products increasing with each passing year, it is important to understand which database best fits your use case. This article lists the top-ranking databases available in the market today. When something that first became popular in the early 1980s is not slowly fading away but is still evolving and becoming more relevant, you know it had to be an important invention. The database is no exception.

How to Include Zero in a COUNT() Aggregate

Explaining how to include zero (0) counts in your SQL query result. Here’s the problem: you want to count something that doesn’t exist, and you want to show your result as zero. How do you do that in SQL? Using the COUNT() aggregate function is a reasonable first step. It will count all the data it finds and return the number of occurrences. But what if there are no occurrences of certain data?

Here’s How I Started Creating SQL Reports

Once upon a time, there was a girl who was just starting her adventure with learning SQL. As a marketer, one of her tasks was writing reports. Previously, she used Excel, a calculator, and written notes to prepare the reports her boss required. One day, it turned out that she could do her job much faster and easier. That was the day she read about SQL reports for the first time.

Is SQL Case-Sensitive?

Is SQL case-sensitive? The question seems simple, and you may think it’s a yes-no question. However, the answer depends on multiple factors. Let’s take a look at the possible answers. First of all, this question can be understood in multiple ways. Which part of SQL are you asking about? Do you mean keywords (e.g., SELECT, WHERE, etc.), table and column names, or values in the columns? Which database management system (DBMS) do you have in mind?

Top 5 MS SQL Server Courses for Beginners

Every journey, including a career change, begins with the first step. If you're thinking about learning data analysis or strengthening your MS SQL Server skills arsenal, you've come to the right place. Here are the top 5 MS SQL Server online courses. Enjoy! You've probably heard that today’s organizations rely heavily on data analysis. You heard right. They are looking for employees who can navigate the world of databases and draw conclusions from data.

Here’s Why You Should Use SQL for Sales Analytics

Would you like to understand how your sales efforts play out so that you know where to put your focus? Do you want to empower your sales teams with sales analytics? This article shows you how you can use SQL to use your sales data to your advantage. If you work in sales, understanding the activities that produce results has financial consequences for you, your team, and your company. This is where sales analytics can really help you.

5 Best Practices for Writing SQL JOINs

These best practices for SQL JOINs will help you make readable SQL queries that deliver accurate, clear, and understandable output. Considering that relational databases are built around related tables, it’s no wonder that SQL JOINs – which allow you to combine information from multiple tables – are one of the primary skills acquired by SQL newbies. SQL JOINs course by LearnSQL.com is the perfect place to refresh your knowledge about JOINs.

Top 5 SQL CTE Interview Questions

Here are five questions (and solutions!) on CTEs you’ll (probably) be asked at an interview. I’m not saying you will get these SQL CTE interview questions at every job interview. But when you do, they are probably along the lines of the five I’m about to show here. Other than theoretical questions about CTEs, there are not that many variations in the CTE scenarios evaluated by interviewers. Go through these five examples, and you get a good foundation for acing your interview!

5 SQL Subquery Examples

SQL subqueries are basic tools if you want to communicate effectively with relational databases. In this article, I provide five subquery examples demonstrating how to use scalar, multirow, and correlated subqueries in the WHERE, FROM/JOIN, and SELECT clauses. A subquery, or nested query, is a query placed within another SQL query. When requesting information from a database, you may find it necessary to include a subquery into the SELECT, FROM , JOIN, or WHERE clause.

SQL for Startups – Do You Need It?

If you’ve been wondering whether to use SQL in your startup, it’s probably high time to do so. SQL can be an amazing tool for small, fast-growing businesses. But don’t worry if you’re unfamiliar with SQL for startups. Maybe you are not sure what SQL is all about. Don’t worry; you don’t have to make any decisions this second! First, answer these questions: Can you think of any data related to your business – prices, clients, details about clients, production details, budget, costs, strategy, or anything else?

What Are Aggregate Functions in SQL, and How Do I Use Them?

Data is your source of knowledge. And thanks to SQL aggregate functions, you can extract the precise knowledge you need from your data efficiently. Read along to find out more. The core SQL aggregate functions are the following: COUNT(column_name | *) returns the number of rows in a table. SUM(column_name) returns the sum of the values of a numeric column. AVG(column_name) returns the average value of a numeric column.

A Chat with Anthony DeBarros, Author of Practical SQL

Some make model ships, others collect stamps. I read SQL books. I've read a lot of them, but only a very few deserve to be called really good. Some of them were included in my Best SQL Books list. The good news is that one of them just got a new release. It was great, even better than the previous edition! Moreover, I was able to talk to its author, Anthony DeBarros.

How to Write a WHERE Clause in SQL

We explain how to use the SQL WHERE clause with practical examples. If you have just started learning SQL and want to know how to retrieve or work with only a specific portion of the data stored in your tables, then this article is for you! The SQL WHERE clause is something you must master if you wish to use SQL for working with data. It is arguably one of the most basic and must-learn constructs of SQL.

How Can SQL Developers Remember Everything They Learn?

Are you at the beginning of your SQL journey? Congratulations, great choice! But you may find the knowledge you gain leaks with time. Find out what SQL developers do to remember everything they learn for a long time. If you learn SQL, the road to the expert level is long, winding, and bumpy. But don't worry – we've all been through it. You know perfectly well it's worth it. And if you don't already know, here are the reasons why you should start learning SQL NOW!

What Is the DELETE Statement in SQL?

This article will explain the use of the DELETE statement, one of the primary methods of removing existing records from your database. First we will run through the syntax, followed by some easy-to-understand examples. The DELETE statement in SQL is extremely useful. It allows you to remove any obsolete or “bad” data from your database tables. You should exercise caution when using the DELETE statement, as the operation is not reversible.

SQL Course of the Month – Window Functions in PostgreSQL

This is what distinguishes ordinary SQL users from professionals – SQL window functions! Would you like to practice them in PostgreSQL, on one of the best interactive SQL courses in the world, and pay nothing for it? Throughout November, you have access to the Window Functions in PostgreSQL course for FREE. You read it right: you won't pay a penny! What's the catch? Why would someone give you a free course?

What Is a Rolling Average and How Do You Compute It in SQL?

In this article, we will show three different examples of using SQL to calculate rolling averages. Learn this and you will take an important step in your SQL growth! A rolling average is a metric that allows us to find trends that would otherwise be hard to detect. It is usually based on time series data. In SQL, we calculate rolling averages using window functions. First, let’s talk about what rolling averages are and why they’re useful.

Top 5 Linux Distributions for SQL

The world is divided into Linux lovers and people who have never tried it before. Still working on Windows or macOS? Do you want to learn SQL? Do you know a large proportion of IT professionals use Linux? It's not a coincidence. But which Linux distribution should you choose for learning SQL? Here's my factsheet to help answer that question.   Linux Distribution: What Is It? What is a Linux distribution?

SQL Date and Time Functions in 5 Popular SQL Dialects

Are you confused by all the date and time functions used across different SQL dialects? In this article, I summarize the date and time data types used in PostgreSQL, Oracle, SQLite, MySQL, and T-SQL. I also provide examples with the key SQL date and time functions used across these dialects. It’s time to become date and time gurus! Do you want to calculate how often employees are running late for work?

New Window Functions Practice Set Is Here!

Have you learned the SQL window functions? Or maybe, you forgot when and how to use them correctly? Are you preparing for an advanced SQL job interview? You've come to the right place! This is the new Window Functions Practice Set. This is very good news for all SQL learners and database professionals who want to improve their skills. The LearnSQL.com Team is proud to present the new Window Functions Practice Set!

The SQL Count Function Explained With 7 Examples

One of the most useful aggregate functions in SQL is the COUNT() function. If you are new to SQL and want to learn about the various ways to use the COUNT() function with some practical examples, this article is for you. The COUNT() function is one of the most useful aggregate functions in SQL. Counting the total number of orders by a customer in the last few days, the number of unique visitors who bought a museum ticket, or the number of employees in a department, can all be done using the COUNT() function.

2021’s Most Popular Databases

What was the most popular database in 2021? And what do you need to know to use it? If you’re learning SQL, you’re in luck. This year’s most popular database uses SQL. But the list doesn’t end there. Read our article and find out the 5 most popular databases this year. My list was based on the latest research of one of the most important platforms in the IT world: Stack Overflow.

What Is a Recursive CTE in SQL?

The article that’ll show you practical examples of using recursive CTEs in SQL. If you’ve heard about SQL’s recursive CTEs but never used them, this article is for you. It’s also for you if you never get tired of recursive CTE examples. Before we dig into recursion, I’ll remind you what CTEs are and what their syntax is. Then I’ll do the same for recursive CTEs. After that, I’ll show you how recursive CTEs work in three examples.

How to Join Only the First Row in SQL

In your projects, you may encounter situations when you have many orders corresponding to one customer or many temperature observations corresponding to the same location, but you only need to join the first row with the most recent order or the most recently observed temperature to the corresponding record in another table. In this article, I’ll go through several ways to do this in SQL. The best way to practice basic and advanced SQL is our interactive SQL Practice Set course.

Still Using Excel for Data Analysis? See Why SQL Is Better!

Are you working with data and still using spreadsheets? Many people think that only programmers or professional data analysts can leverage SQL for data analysis. In this article, I’ll show how people with no IT background can use SQL for their daily work tasks. Not all people working with data have the corresponding job titles like data scientist, data analyst, or data engineer. Following the data democratization trend, almost all office workers do something with data as part of their daily duties – marketers analyze advertising campaigns, HR specialists analyze employee dynamics, auditors analyze credit portfolios, etc.

Read These 5 Data Analysis Books to Jump-Start Your Career

Do you want to pivot into a data analyst role, but you are unsure where to start? Do you do analytics in your job and would like to learn more about the big picture of data? Are you looking for a great data analysis book to read? In this article, you will find our selection of the best books on data analysis! If you are a business professional thinking about picking up data analytics skills, you may be wondering how you should start.

Numeric vs. Decimal Data Types in SQL

In standard SQL, there is a slight difference between the NUMERIC and DECIMAL data types. However, in some variants of SQL, there is no difference! This article will clear up any confusion. In this article, I’ll explain the differences and similarities between SQL’s standard NUMERIC and DECIMAL data types. Then I’ll discuss how these data types work in common SQL dialects. We’ve already posted a more general article on SQL data types; this time, we’ll drill down further on just the DECIMAL and NUMERIC data types.

How to Sort Values in a Specific Order in SQL

Sometimes you will be required to order your data in a particular way, and often the use of typical sort modifiers like ASC and DESC are not enough. This article will show you how to use the CASE statement to order your data exactly how you need it to be. Have you ever needed to order your data in a very specific way? One of the best methods for handling complex sorting is using CASE.

How to Use CASE in ORDER BY in SQL

This article will show you how and when to use CASE in an ORDER BY clause. Have you ever used a CASE statement? I’m sure you have, at least in a SELECT statement. But have you ever used it in an ORDER BY clause? No? You will, once I show you how! Don’t worry if you’ve never used a CASE statement. I’ll show and explain it to you with a short example.

How SQL Helps Everyone in Your Office

I don't know about you, but I really like to make my life easier. If something can be done faster and more efficiently, especially if it's everyday, routine tasks, I’m all for it! This is where SQL works brilliantly. It's not just about complicated data analysis. Everyone in the office works with different types of data, and SQL can help anyone. How? Anything is possible once you learn SQL!

Best Places to Practice SQL JOINs Online

You’ve just started your journey with SQL and you’re not sure what a JOIN is or where to use it. Don’t worry! In this article, you will find out what JOINs are and where you can practice them online. If you have just started learning SQL, you have a lot of topics to cover before you can call yourself a data professional. If you are serious about using SQL, you’ll have to understand JOIN – what it does, when you can use it, and what its different variants do.

Free Course of The Month – SQL Practice Set in MS SQL Server

You have to train a lot to learn a new skill. It is the same with MS SQL Server. Do you want to write good SQL queries? Or maybe you are preparing for a job interview? You've come to the right place! Throughout October you will have access to our amazing hands-on MS SQL Server course for FREE! You probably just thought: “There must be a catch. Why would someone give away SQL courses for free?

Difference Between ROWS and RANGE in Window Functions

Are you familiar with ROWS and RANGE window functions but not sure how they are different? This article makes those differences clear. In using SQL window functions, you’ve probably come across ROWS and RANGE clauses. If you haven’t, they are both parts of the Window Functions course. If you have, it’s quite likely you have been left confused why there are two keywords for the same function. Well, they are not the same!

7 Things Every Data Engineer Should Know

People generate massive amounts of data every day. To get insights from data, organizations need to capture and process them efficiently. That is when data engineers are called up. In this article, I’ll discuss the data engineering role and the skill set necessary to succeed in the role. As the world generates more and more data every year, the IT industry creates new roles to deal with it. These roles include data analysts, data scientists, machine learning engineers, and data engineers.

Find Top Salaries by Department with SQL

This article shows how to get the total salary by department for an organization, using the GROUP BY functionality of SQL. We explain the SQL GROUP BY clause in detail along with conditional filtering using a HAVING clause. Understanding the salary outlay for an organization is one of the common starting points for business leaders. It helps them see who in the organization has the highest total salary cost, department-wise.

The 7 Best Articles about the SQL Recursive Query

Do you want to learn about recursive queries but don’t know where to start? Here’s our selection of seven articles that should help you with diving into the recursive queries world. I won’t lie to you. Learning and understanding recursive queries can be difficult. But difficult things are usually worth trying. And by learning recursive queries, you’re making sure you know how to work with this very powerful tool.

5 Practical Examples of Using ROWS BETWEEN in SQL

SQL window functions are tremendously useful for calculating complex aggregations like moving averages or running totals. The ROWS clause allows you to specify rows for your calculations, enabling even more sophisticated window frames. Here are five practical examples of leveraging the ROWS BETWEEN clause in SQL. Window functions (also called OVER functions) compute their result based on a sliding window frame (i.e. a set of rows). They are similar to aggregate functions in that you can calculate the average, total, or minimum/maximum value across a group of rows.

How to Export a CSV File From a T-SQL Query

Knowing SQL queries to select data from databases allows you to obtain information easily. However, there are many situations in which we need to export data to another platform or application. The CSV file is a solution to this problem. If you'd like to master complete SQL, try out our interactive SQL from A to Z track. It contains 7 hands-on SQL courses that will take you from a beginner to an advanced SQL user.

How Developers Can Build SQL Skills

Even though you cannot build an application using SQL, employers continue to add SQL skills to their job requirements for software developers. In this article, I’ll elaborate on why developers need to know SQL and how you can learn SQL most efficiently. As a developer, you may work on different kinds of projects. Not all of your projects require doing string manipulation, but that doesn’t mean you don’t need to know how to do this.

Top 10 Tools for Business Analytics

Business Analytics is one of today’s hottest career fields. However, success as a business analyst requires that you learn the right skills and software programs. Let’s see what tools you should know if you want to be a business analyst. With the world generating immense amounts of data – and having systems in place to capture and manipulate that data to fuel business growth – job opportunities for business analysts are only going to grow.

How to Use Aliases with SQL JOINs

SQL aliases are custom names that you can give to the columns and tables you include in your queries. Aliases are very useful, as they can greatly improve the readability and maintainability of your query. We’ll be taking a closer look at using SQL aliases with JOIN and why you might need to do so. The best way to master aliases in SQL is practice. I recommend our interactive SQL Practice Set course.

Frequently Asked Questions About SQL

Ten SQL questions that you should be able to answer if you’re applying for an SQL job. SQL is a vast topic and a source of endless questions from its users. However, some questions are asked more frequently – usually about concepts that most SQL users will need to know. It’s not surprising that interviewers tend to ask these same questions to SQL job candidates. Either way, knowing these questions is a first step to learning SQL.

Top 5 SQL Audiobooks

No time to learn SQL? What if I said you could learn while sitting in traffic or washing dishes? It’s possible thanks to SQL Audiobooks. Check out which ones you should listen to. I have been recommending various SQL books for a long time. If selected well, they can be a great complement to the knowledge gained in interactive online courses. If you haven't read my article yet, check it out.

How to Show Your Sql Experience

Do you want to work in the IT industry? This is now one of the best ideas for a good career. What should convince you to do so? Demand for specialists, high earnings, and the fact that it is a future-proof profession. Interestingly, it's not gonna be that hard – especially for you, smartie! You just need some skills and good preparation for an interview to be successful. I'll tell you how to land a great job!

Fall 2021 Track of the Season: SQL from A to Z

The ability to analyze data is one of the most sought-after skills in job applicants. Why? Because all organizations want to take advantage of the power of data. And one of the basic tools for that is SQL! See why we have chosen the SQL A to Z track as our track of the season. This fall, take your analytical skills to the next level! Let's start with the basics.

Why You Should Use SQL in Marketing Analytics

Have you been wondering how you could use SQL in your marketing data analysis work? Would you like to create SQL reports to guide your marketing decisions? In this article, you will learn how to use SQL for marketing through plenty of use cases. Are you a marketing professional wanting to better understand the results of your marketing efforts? Do you want better means to prove your point and demonstrate the value you create?

How Hard Is It to Learn SQL Without IT Experience?

Updated on: September 12, 2023 Learning SQL doesn't have to be difficult! Taking an interactive SQL course is a great way to start your career in the high-paying world of IT. When you started your adventure with computers, you surely didn't realize how far you could go. You were probably only a few years old, and your first experience with a computer was probably gaming. Today, computers provide more than just quick access to entertainment; they’re a great tool for earning money.

Free Course of the Month: SQL Server Revenue Analysis

It is impossible to run a business without a good analysis of revenue trends. But how do you do it effectively? You can rely on good old Excel, but a much better idea is to use SQL and databases. Learn how to create SQL reports and track the growth of your business with MS SQL Server. Here is the course, Revenue Trend Analysis in SQL Server. It’s FREE throughout September!

SQL MIN and MAX Functions Explained in 6 Examples

What are the SQL MIN() and MAX() functions? When should you use them as aggregate functions, and when should you use them with window functions? We explain using practical examples. It’s difficult to imagine SQL without the MIN() and MAX() aggregate functions. They are very useful among many data professionals because they allow us to resolve a lot of business problems. In this article, I will explain what each function does and discuss several use cases.

How Much Do Data Analysts Earn in 2021?

How Much Do Data Analysts Earn in 2021? How much does a data analyst earn? We did some data analysis ourselves. Nothing fancy, but it will give you some extra motivation for learning SQL for your data analyst gig. Data, data everywhere! We live in the world of (big) data. Having data is just the first step. Knowing what to do with it, how to interpret it, and what insights it holds, is true greatness.

3 Real-Life Examples for SQL Common Table Expressions

We answer three SQL business questions using CTEs. There are business problems that are often solved in a very roundabout way. While they might get you the correct result, there’s usually a more elegant way to write a solution. Enter the CTEs! They are extremely helpful when it comes to getting a more direct and elegant solution. I’ll show you three business situations where CTEs can be very helpful. You’ll get an idea of when CTEs can be useful.

Why Is the SQL Practice Set my Favorite Online Course?

My friends know that I cannot sit still. I always have to do something, read something, and learn new stuff. It's stronger than me. But I don't complain, because this approach has only helped me in my life. I have done a ton of different online courses, but the SQL Practice Set has proved to be the best so far. Find out why. Learning SQL was not easy for me.

Standard SQL Functions Cheat Sheet

Welcome to the ultimate resource for mastering SQL functions - the Standard SQL Functions Cheat Sheet. It's designed to be a quick yet comprehensive reference guide for both beginners and experts. Download yours and start querying with ease. Whether you are a beginner stepping into the world of SQL or a seasoned professional looking to brush up on your skills, our Standard SQL Functions Cheat Sheet is designed to be your go-to guide for SQL functions.

Best SQL Courses for Business Owners

Do you have a business? Can you use the data you collect every day? You would probably do anything for it to succeed. Learn SQL and achieve your goals. Here are the best online SQL courses for business owners. SQL is a great tool that allows you to work with databases. Are you looking to acquire a skill or two to help your business grow? SQL is the answer!

Why You Should Work in a Data-Driven Company

Does accessing and using data collected by your company feel painful? Have you heard about data-driven companies? Working in a data-driven company may give you the ownership and the opportunities to use your company’s data. Read our article to learn more! If you work in a company, chances are that you want to do data analysis to solve problems. However, this is often not easy. You face many obstacles, impeding access to the data you need.

The SQL AVG() Function Explained With Examples

We explain the SQL AVG() function with practical examples, covering how and where you can and cannot use it. The average is probably one of the most widely used metrics to describe some characteristics of a group. It is so versatile and useful that it can describe something about almost anything. If you like sports, you see things like average runs per game in baseball, average assists per game or per season in basketball, and so on.

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.

How to Use CASE in SQL

Updated on: February 19, 2024 If you need to evaluate multiple conditional statements, the SQL CASE statement will do the job. To effectively harness CASE in SQL, grasping its structure and practical uses is key. I'll guide you through real query examples showcasing the power of this versatile statement. Here’s what you need to know to use CASE like a pro. Why is CASE so important in SQL? If you’re analyzing or manipulating data, you’ll often want to define rules based on certain conditions, e.

An Overview of MS SQL Server Data Types

SQL Server data types define what can be stored in a column, local variable, expression, or parameter. It is essential to pick the right data type. Ultimately. your choice of data types affects the whole database. Read on to learn about all of the data types available in MS SQL Server. In this article, we’ll cover numerical, text, and date and time data type categories in detail. We’ll go through their syntax, storage size, and typical use cases.

How to Find the Nth-Highest Salary by Department with SQL

Learn how to find the nth-highest salary in SQL, and you’ll learn how to get the nth value in any data. In this article, I’ll focus on one problem and give you several solutions to that problem. The problem is stated in the title already: find the nth-highest salary by department using SQL. This may sound too specific. But by learning how to solve this, you’ll be able to find the nth value in any data, not just salaries.

What Is the UPDATE Statement in SQL?

The SQL UPDATE statement is used to update existing data in your database. This article will explain its syntax and show you clear examples of the UPDATE statement in action. Effectively updating existing data in a database is required for anyone using SQL; data is only useful if it is kept up-to-date and relevant. In this article, we’ll examine the syntax of the UPDATE statement in great detail. Then we’ll dive into detailed step-by-step examples that will drive home the rules, potential uses, and limitations associated with the SQL UPDATE statement.

I Needed a Good SQL Course… So I Chose SQL Basics.

Why did I decide to take a SQL course? And how did I come across LearnSQL.com? It’s story time! Did I ever think that my professional career would deal with databases? Absolutely not. It didn’t even cross my mind that it would happen. Let me explain why I started learning SQL … and how I got to where I am today. Meet the SQL Newbie I suppose few people have their lives planned from A to Z.

How to Define a Window Frame in SQL Window Functions

The window function is a super powerful resource of the SQL language. At the core of any window function, there is a set of records, called the window frame, defined using an OVER clause. Knowing what records are in the window frame, how they are ordered, and what their upper and lower bounds are, are critical in understanding how window functions work. In this article, we will analyze and explain with examples how you can define different types of window frames.

Use SQL on a Movie Database to Decide What to Watch

We’ll demonstrate how to use SQL to parse large datasets and gain valuable insights, in this case, to help you choose what movie to watch next using an IMDb dataset. In this article, we’ll be downloading a dataset directory from IMDb. Not sure what to watch tonight? Are you browsing Netflix endlessly? Decide what to watch using the power of SQL! We’ll be loading an existing movie IMDb dataset into SQL.

Free Course of the Month: SQL Reports in SQL Server

This is another in our series of free SQL Courses of the Month. This time, you can learn SQL Reporting in MS SQL Server for free. Do you want to be able to prepare even better SQL reports? Or maybe you have some basic knowledge of SQL Server (one of the major SQL dialects) and would like to go a step further? This is the course for you.

New to Data Engineering? Don't Make These Mistakes

It's best to learn from the mistakes of others. This advice also works for data engineering. In this article, you'll find tips to help you advance your career and avoid common data engineering mistakes. The data revolution has produced tremendous opportunities and created various high-paying jobs related to the collection, maintenance, and manipulation of data. Data engineering is one of the most lucrative and interesting jobs of this family.

How to Use SQL to Calculate Customer Lifetime Value (LTV)

Working with data is an essential skill for marketers in today's data-driven world. As a marketer myself, I decided to create a series of articles about calculating key performance indicator (KPI) metrics for SaaS (Software as a Service) companies. We’ll start by calculating customer lifetime value (LTV) using SQL. Data is one of today’s most valuable resources. If you work in a SaaS company, you are flooded with a huge amount of data every day.

An Overview of SQL Text Functions

In this article, we will discuss the ins and outs of the most common SQL text functions, which make it possible for you to find and work on string values. Before we dive into text functions, let’s quickly recap what an SQL function is. Simply put, a function is a predefined built-in piece of code that you can use in your SQL query. For example, the functions SUM(), AVG(), and COUNT() are applied to numerical variables to calculate the sum, average, and number of records respectively.

How to Improve New Employee Onboarding with SQL Courses

Are you looking for something to improve the onboarding process of new employees at your company? If they will be working with databases and SQL, and if you need resources for them to learn quickly, choose interactive SQL online courses. You’ve just hired some new employees. Great! After a long recruitment process, you have finally managed to find people who can do the job and meet your expectations. You may have even used our advice on why it makes sense to Practice SQL Before Interviewing a Potential Employee.

SQL SUM() Function Explained with 5 Practical Examples

Aggregate functions are an important part of SQL knowledge – and there’s no better place to start learning them than with the SUM() function. In this article, you can expand or refresh your SQL with 5 practical examples of SUM(). SQL allows us to do more than select values or expressions from tables. Most operations on relational databases use aggregate functions like SUM() to do computations on data.

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.

How to Keep Unmatched Rows When You Join two Tables in SQL

Learn how to use JOIN to keep both matched and unmatched rows when you join two tables. Joining two or more tables is a skill you need a lot if you’re working with databases. To review and practice your SQL joining skills, I recommend the interactive SQL JOINs course. It contains over 90 exercises and sections on different joining challenges. If you often join tables in SQL, you’ve probably noticed not all data from one table corresponds to data from another table all the time.

Top 10 SQL Window Functions Interview Questions

Many interesting job positions require SQL skills – and that includes window functions, which are not commonly taught in online courses. In this article, I will cover the top window function questions for every experience level. If you’re going for a job interview for an advanced SQL position or for intermediate to advanced data analyst positions, you’ll probably be asked about your knowledge of SQL window functions. Don’t panic! Although these functions aren’t commonly covered in online courses, we’ve got the answers right here.

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.

SQL Track of the Season: SQL Reporting in MS SQL Server

It's the best time of the year for a change! Learn something new and boost your career! This is our SQL Track of the Season: SQL Reporting in MS SQL Server! In this article, we’ll answer common questions about this track. Summer is here. Does the sun make you want to learn something new? Maybe surfing or Portuguese? Maybe you've wanted to learn crocheting all your life? Follow your dreams!

What Is the SQL GROUPING SETS Clause, and How Do You Use it?

GROUPING SETS are groups, or sets, of columns by which rows can be grouped together. Instead of writing multiple queries and combining the results with a UNION, you can simply use GROUPING SETS. GROUPING SETS in SQL can be considered an extension of the GROUP BY clause. It allows you to define multiple grouping sets in the same query. Let’s look at its syntax and how it can be equivalent to a GROUP BY with multiple UNION ALL clauses.

Best SQL Certifications for Leveling up Your Career

If you want to build and strengthen your position in the IT industry, you should look into these SQL certifications. We always encourage you to learn, to gather new skills and experience. Training is really important; without it, you will not make much progress if you want to advance in IT or specifically in the SQL industry. That said, you also need something that can validate your competencies, like SQL certifications.

What Is the INSERT Statement in SQL?

The INSERT statement in SQL is used to add new data to your database. This article will explain how to use it and show you practical examples along the way. When you learn SQL, you focus on getting data out of a database, working mostly with SELECT. In SQL, there are also statements that let you modify data in a database. The first one is the INSERT statement: it adds data to a table.

Primary Key vs. Unique Key: Explaining the Differences

When designing a database, we often need to decide between defining a primary key vs. a unique key. Both of them are crucial during the design and further phases of a database. They allow us to uniquely identify each row, ensure the uniqueness of values in the column(s), and more. Let’s take a deep dive to learn more. This article will go through the primary and unique keys, their functions, and features.

RANGE Clause in Window Functions: 5 Practical Examples

What is a RANGE clause in SQL window functions? Five practical examples will show you how and when to use it. The RANGE clause is used quite rarely in SQL window functions. I don't know why; maybe people are not used to it. This is a shame, because it's far from a pointless clause; it can be very useful, and I'll show you that in five examples. To learn how window functions work, what functions there are, and how to apply them to real-world problems, it’s best to take the Window Functions course.

How to Learn SQL Faster

Struggling with learning SQL? Does it seem like you’re doing everything right, but not making progress as fast as you’d like? Don't worry, I'll help you. Here are some tips for learning SQL quickly and painlessly. Are you wondering how to learn SQL faster? If so, I’m here to help with some practical tips. And once you’ve found the right motivation and the right sources of knowledge, you’ll be able to learn faster.

Free Course of the Month: SQL Server Recursive Queries

Do you want to become a SQL expert? To do this, you need to learn SQL CTEs or Common Table Expressions. They can make your queries clearer and more readable. And during July 2021, you can learn CTEs for free using our interactive Recursive Queries in MS SQL Server course! How can you get this free SQL course? Create a free LearnSQL.com account or log in if you already have one.

Top 15 SQL Interview Questions in 2021

If you are on the lookout for a job in the field of data, you’re almost guaranteed to face SQL interview questions. You might even be asked to complete some kind of SQL coding test. According to KDnuggets, irrespective of the specific role in data – data analyst, data engineer, data scientist, or business intelligence analyst – SQL lands in the top three skills found in postings across Indeed, SimplyHired, and Monster.

Skills Every Data Analyst Should Have

If you’re a student looking for career advice or a specialist seeking new job opportunities, find out if a data analyst job is something worth considering. In today's article, I explain the essential skills required for data analysts and benefits that come from performing such a job. What Is a Data Analyst? Let’s start by defining exactly what a data analyst is. A data analyst is someone who uses their skills to collect, analyze, and report insights from company data.

Data Analyst vs. Data Engineer: A Full Comparison

Do you want to become a data analyst? Or maybe you dream about being a data engineer? Can't make up your mind? I'll help you. Read about the two roles’ history, their market situation, and the skills you need to become one. You already know that it's a good idea to enter the data world and work with databases. But how to do it? Behind which door is the better career waiting for you?

New Basic SQL Practice Course on LearnSQL.com

Hey, did you hear that there’s a brand-new Basic SQL Practice course on LearnSQL.com? This is a great opportunity to refresh your SQL, write some queries, and take your analytical skills to the next level. We’re proud to introduce Basic SQL Practice: A Store! Where did the idea for this new SQL practice course come from? From our users! They’ve let us know that they need more hands-on SQL exercises at a beginner level.

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.

Why Does Your Company Need Data Analysis?

Data is the new gold. That is what the biggest in the business say, knowing the value of the data, the analyses, and the conclusions they bring. If you are wondering why your company needs data analysis and what value it could bring to your business, then this article is for you. Historically, many companies have gone into analytics mainly through financial and accounting data to improve revenue, reduce costs, and eventually increase profitability.

An Overview of PostgreSQL Data Types

It’s vital to know what you actually store in your database. That’s why every column has its data type. There are numerous PostgreSQL data types across various categories. Read on to see which data type suits which use case! In this article, we’ll go through the most common data types used in PostgreSQL. PostgreSQL, also called Postgres, is a well-known open-source object-relational database management system (DBMS). It is SQL-compliant, extensible, and includes all standard relational database features, such as database constraints, transactions, views, triggers, stored procedures, and more.

SQL Terms Beginners Should Know - Part 4

Here it is – another batch of must-know SQL terms. In the first two parts, we covered tables, relational databases, queries, aliases, SQL JOINs, primary keys, and subqueries. Last time, we moved to more advanced terms like INSERT INTO, GROUP BY, and HAVING. Are you ready to dive deeper into SQL terminology? This is the fourth installment of our series on basic SQL terms for beginners (and everyone else). Don’t worry if you missed the previous articles; you can find Part 1 (essential SQL terms), Part 2, and Part 3 in our blog.

Business SQL: How to Calculate Revenue Growth in SQL

Can you use SQL in business? Of course you can! For example, you can calculate revenue growth in SQL – here’s how. As someone who works with data, you already know that SQL is the most used tool in data analysis. But how is SQL helpful in business use? Well, the answer is obvious: analyze business data using SQL! However, there are some specifics with business data that can be tricky if you’re not used to it.

I Took the SQL Basics Course... Here's What Happened!

In this article, I will share my personal story with you. But don't worry – it's not about a scandal or a sad story of failure. I'll tell you how a successful news journalist fell in love with SQL. It all started when I took the SQL Basics course at LearnSQL.com. There are moments in life that change everything. Mine happened when I decided to give up my long-term career and start a completely new chapter in my professional life.

How to Draw Pictures with Recursive SQL Queries

Did you know that SQL can be used for fun? You can even ‘draw’ in SQL using recursive queries! Find out how in this article.  As an SQL user, you already know this language is great for data analysis and data manipulation in general. This is something people get very serious about. But you can also have fun with it by drawing ASCII-art pictures using the SQL code. To do that, you have to know how recursive SQL queries work.

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.

Free Online Courses You Should Take If You Use SQL

If you are an SQL enthusiast, already work with SQL, or want to learn it – you'll surely be interested in acquiring new skills that will support your growth. These free courses will increase your productivity, help you find your way around the work environment, and help you become a better analyst. By the way, they are also fun. Whoever said learning new things is easy has never tried to learn quantum physics (thank you, Mr.

How the Division Operator Works in SQL

The division operator in SQL is used to divide one expression or number by another. This article will show you exactly how to use it and common mistakes to avoid along the way. The best way to practice SQL is our interactive SQL Practice track. It contains over 600 hands-on exercises that conver varios SQL topics, from simple one-table queries, through JOINs, to complex topics like subqueries. It lets you train your SQL skills on real business examples.

A Brief History of MS SQL Server

Microsoft SQL Server is one of the best database management systems in the world. It’s constantly improved and widely used. But do you know how it was created? In this article, I’ll show you the history of MS SQL Server, a solution that changed the world of databases. We’ll explore the stages of MS SQL Server development, find out how the current version differs from the original, and talk about where you can learn or practice SQL Server.

Free Course of the Month: SQL Server GROUP BY Extensions

Do you create SQL reports? Do you want them to be even better and more effective? Are you working with MS SQL Server and want to expand your query writing skills? Here is a great, interactive GROUP BY Extensions in MS SQL Server course. For the month of June, you can learn and finish this course for absolutely free. How can you get this free SQL course in June?

UNION vs. UNION ALL in SQL: What’s the Difference?

UNION and UNION ALL are both used to retrieve records from multiple tables. This article will detail the differences between the two, allowing you to make the best choice for each unique scenario. You can use SQL’s UNION and UNION ALL commands to get data from multiple tables in your database. It’s a common use case, considering that most databases have many tables. Both UNION and UNION ALL are known as set operators.

Where Can I Find a Data Analyst Internship?

Are you wondering how to land a data analyst job without any professional experience? This article is the answer! Finding an SQL-related internship – an important part of eventually landing a data analyst job. Internships enrich your CV and, more importantly, help you learn SQL from the practical side. I will tell you where to find data analyst internships and what you should know about them. That's right! To gain experience, you need experience – especially when you’re entering the labor market or embarking on a new career.

How to Compute Year-Over-Year Differences in SQL

How did your business do this year compared to last year? The year before? Find out how to use SQL to calculate year to year and month to month differences. Year-over-year (YOY) comparisons are a popular and effective way to evaluate the performance of several kinds of organizations. Year to year differences are easy to understand – e.g. it’s easy to understand that your revenue growth is 35% year to year.

How to Keep Focused While Learning SQL

Learning SQL can be a challenge, but it’s one you can handle! I’ve prepared 5 tips to help you stay focused during your learning journey. By choosing the right methods and tricks, you can achieve your goals! If you’re interested in learning SQL, I bet that you are a very ambitious person who wants to constantly develop. You may even be taking your first steps in your career. I don't think I need to explain to you the obvious advantages of learning how to operate database systems; Data is everywhere, applies to everyone, and is increasing by the day.

8 Best SQL Window Function Articles

Do you need a starting point for learning SQL window functions? Not sure which articles provide a solid foundation? We dove into the internet rabbit hole and found the eight best articles dealing with window and analytic functions. There are plenty of articles dealing with SQL window functions. Type those words into Google and you’ll find a huge number of articles returned. Reading articles is a good start if you want to learn something about window or analytic functions in SQL – provided, of course, that the articles you choose are trustworthy and up to date.

What’s the Difference Between UNIQUE and DISTINCT in SQL?

We use the words unique and distinct interchangeably in our day-to-day life. However, these words play very different roles in SQL. Let’s find out what is so different about them and how we can use them in SQL. Despite the words unique and distinct being synonyms, they cover very different things in SQL. The UNIQUE keyword in SQL plays the role of a database constraint; it ensures there are no duplicate values stored in a particular column or a set of columns.

What Is Advanced SQL?

Are you confused about advanced SQL skills? What are they? This article will explain what advanced SQL can mean, especially as we use it on LearnSQL.com. I’m sure you find the phrases ‘advanced SQL skills’ or ‘advanced SQL topics’ very often. You read one article about advanced SQL and you’re happy with how easy these advanced topics seem to be. Then you talk to someone and you see they consider everything you know as basic SQL knowledge.

How to Use Aliases in SQL Queries

An SQL alias is useful for simplifying your queries and making the query and its result more readable. This article explains why and how you can use aliases in your SQL queries. You can temporarily rename a table or a column by giving it another name. This is known as an SQL alias. It’s a temporary change that does not affect the actual table name in the database. A temporary table name can also be called a correlation name.

How to Use Comparison Operators with NULLs in SQL

The SQL NULL value serves a special purpose. It also comes with counterintuitive behaviors that can trip up SQL beginners or even experienced programmers. Learn how to avoid these problems when you use NULL with comparison operators. This article is going to help you master best practices for crafting SQL queries that work with NULL values and use comparison operators ( =, <>, <, > ) – which, if you have written any SQL queries before, you know is just about every query you will ever write!

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.

The Best Books for Data Engineers

Are you tired of staring at a computer all day? Maybe it’s time to read a book. Take a moment to check out our list of recommended books for data engineers. They will help you deepen your knowledge about databases. Last year, we shared a list of the best books to learn SQL. This time, I want to introduce five books for data engineers. They are worth reading and will help you learn more about databases.

Best Online SQL Courses for 2021

In this pandemic era, it's no surprise that online learning has become even more popular. To help you narrow things down, I’ve prepared a list of 2021’s 10 best online SQL courses. Find out where you can learn SQL effectively! The number of online courses on offer – especially in the tech industry – is now impressive. You can find something that suits your interests, competences, and professional ambitions. But how do you know which to choose among the many online SQL courses out there?

What Is the WITH Clause in SQL?

In this article, you will learn about the SQL WITH clause, also known as common table expression (CTE). We will go over some examples to demonstrate some of their use cases in light of their benefits. Introduction to the SQL WITH Clause The WITH clause in SQL was introduced in standard SQL to simplify complex long queries, especially those with JOINs and subqueries. Often interchangeably called CTE or subquery refactoring, a WITH clause defines a temporary data set whose output is available to be referenced in subsequent queries.

Want to Work With Data? Learn SQL!

Are you looking for a database job? How are things working out? If you don't know what to do, I suggest you start by learning SQL. Here’s why. In this article, I’ll explain how you can succeed at finding a database job. If you are tired of your current job and fed up with your boss (who hasn't given you a raise in years), read on. Stay with me too if one more stupid Zoom call will make you scream.

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.

SQL Course of the Month – SQL Practice Set

Are you starting your adventure with SQL and looking for a place to practice your SQL queries? Or maybe you are preparing for a job interview? I have good news for you. Throughout May, you will have access to our amazing SQL practice course for FREE! Why is LearnSQL.com giving you a free SQL course? Every month, our users get the opportunity to take one of our great SQL courses for free.

Why Do You Need a Primary Key in a Database Table?

What is a primary key and why is it so important in SQL? Find out in this article. Primary keys are a central element in SQL databases. They provide a unique value that can identify a specific row in a table, which opens up a lot of other benefits. This article covers what a primary key is, how it works, and how to use it in an SQL database.

Breaking With Filing Cabinets: The History of PostgreSQL

This July, PostgreSQL turns 25. It has had an extensive influence on computing. Thanks to PostgreSQL, the world said “Goodbye!” to filing cabinets as the standard for storing and processing data. So, who created PostgreSQL, and how has it changed over the decades? There are quite a few PostgreSQL enthusiasts among my colleagues at LearnSQL.com. It is simply a great database solution. Why? It is free and open-source. So, you can use it for free, even for commercial uses.

What Is the Benefit of Foreign Keys in SQL?

What is a foreign key and why is it so important in relational databases? Learn all the details about foreign keys in this article. One of relational databases’ key features is the ability to link data stored in different tables. These links, called references, essentially act as connections between tables. They are created using the FOREIGN KEY constraint on table columns. In this article, we’ll learn what the FOREIGN KEY constraint does in SQL.

What Is the Role of DISTINCT in SQL?

The DISTINCT keyword in SQL plays an important role in removing duplicate values from your results. This article provides examples showing exactly how DISTINCT works. By default, SQL queries show all the returned rows, including duplicate rows, in the result set. The DISTINCT keyword in the SELECT clause is used to eliminate duplicate rows and display a unique list of values. In other words, the DISTINCT keyword retrieves unique values from a table.

What Do the SQL INTERSECT and MINUS Clauses Do?

Do you know the difference between SQL’s INTERSECT and MINUS clauses and how to use them? You will find examples and explanations in this article. SQL INTERSECT and MINUS are useful clauses for quickly finding the difference between two tables and finding the rows they share. INTERSECT compares the data between tables and returns only the rows of data that exist in both tables. MINUS compares the data between tables and returns the rows of data that exist only in the first table you specify.

Hierarchical Data and How to Query It in SQL

How do you recognize hierarchical data, and how do you query it? Two common SQL questions are about to be answered. Querying hierarchical data is a rather common situation if you’re working with SQL and relational databases. Not that hierarchical data is something mystical and rare; on the contrary, it’s everywhere. So why is hierarchical data so challenging when it comes to relational databases? Mainly, the difficulties occur in translating hierarchical data to relational database principles.

Analyze Small Datasets with SQL

If you think SQL data analysis is useful only when a business is generating millions of rows of data – that SQL cannot help you if you are generating a limited dataset – think again and read on! There is so much talk about how SQL is useful in analyzing Big Data that sometimes the applications of SQL data analysis for small datasets can go unnoticed. Having worked with early-stage businesses – which have just started generating data through daily transactions – as well as big established clients generating terabytes of data, I can tell you for sure that SQL can be an extremely handy tool for just about any business.

Does Music Improve Work Efficiency?

Updated on: April 15, 2024 Do you sometimes have trouble focusing when working or studying SQL? Do you ever lack motivation? I have the perfect solution for you: music for learning SQL! I am excited to tell you about how the right tunes can significantly enhance your efficiency and concentration. Music can soothe the savage beast, they say. It can also inspire action. In general, music is an important element of human life.

Who Should Learn SQL?

If you learn SQL, will you use it in your current (or dream) job? If you learn it, will it help you with your daily tasks? SQL has so much potential that everyone can benefit from it – including you! Read this article to find out how much you will gain by knowing SQL. I could answer the title question with one word: everyone! But not everyone wants to learn SQL.

What FULL JOIN Is and When to Use It

Learn about FULL JOIN, how to implement it, how it compares with the other types of SQL JOINs, and some of its unique use cases. Before we jump into FULL JOINs, let’s quickly recap what an SQL JOIN is. At its core, a JOIN combines data from two or more tables within a database. Tables are usually linked together using unique identifiers in each table, i.e. primary and foreign keys.

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. Table of Contents Introduction to JOIN INNER JOIN Example #1: Showing books and their authors Example #2: Showing books and their translators LEFT JOIN Example #3: Showing all books alongside their authors and translators, if they exist Example #4: Showing all books with their editors, if any RIGHT JOIN Example #5: Books and editors with RIGHT JOIN FULL JOIN Example #6: Showing all books and all editors Example #7: Showing all books, authors, editors, and translators Time to Practice SQL JOINs!

SQL CTE Explained

In this article, you will learn about SQL Common Table Expressions (CTEs). This powerful SQL tool will help you simplify complex queries. Additionally, I will introduce you to the two main types of CTEs and some of their use cases.  CTE Primer The Common Table Expression (CTE) was introduced to standard SQL to simplify long, complex queries (especially joins and subqueries). It is a temporary data set returned by a query that contains data separate from the main query.

SQL Track of the Season: SQL Fundamentals in PostgreSQL

Are you ready for a new challenge this spring? Check out our SQL Track of the Season: SQL Fundamentals in PostgreSQL! In this article, we’ll answer common questions about this track. It’s getting warmer. The flowers are slowly beginning to bloom. This can mean only one thing – spring is here. The world is coming to life after its wintertime lethargy. This is a great time for new challenges. Do you want to add something to your skillset?

How to Find the Next Non-NULL Value in SQL

You need to find the next non-NULL value in a time series, but you don’t know how. Can you even do that in SQL? Yes, you can! This article will show you what to do. If you work with SQL, you will sooner or later confront NULL values. Having NULLs in a database is almost unavoidable. However, sometimes you want to avoid them in your reports. This is quite often true when you’re analyzing time series data; NULL values mean there’s no data available.

What Is the RANK() Function in SQL, and How Do You Use It?

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.

Free SQL Course of the Month – Creating Basic SQL Reports

Do you want to create good SQL reports from scratch? Are you looking for a course that will help you spread your analytical wings? What if I told you that throughout April 2021, you could access one of the best SQL Reports courses for FREE? Here it is: Creating Basic SQL Reports. What's the catch? There is none. LearnSQL.com provides one of their courses for free from time to time.

What Is CASE in SQL?

SQL CASE is a very useful expression that provides if-else logic to your SQL queries. It’s a slightly more advanced topic, but you’ll need it when preparing reports – it will deliver massive value to your personal and professional projects. The SQL CASE statement is a control flow tool that allows you to add if-else logic to a query. Generally speaking, you can use the CASE statement anywhere that allows a valid expression – e.

How to Install MS SQL Server 2019 on Windows

Do you want to install SQL Server 2019 on your Windows PC? How about the latest version of SQL Server Management Studio? I’ll walk you through the process. Soon you’ll be writing T-SQL queries and operating on SQL Server databases! As I write this article, Microsoft SQL Server 2019 is the latest version of SQL Server. It’s the 15th version of one of the most popular database servers in the world.

Is MS SQL Server Still Worth Learning in 2024?

Updated on: March 10, 2024 MS SQL Server is an in-demand skill in today’s job market. Should you learn  MS SQL Server in 2024? In this article, I’ll answer this question. Thinking about whether you should dive into Microsoft SQL Server in 2024 – especially with so many free database alternatives available? MS SQL Server has been a go-to for handling data for ages, thanks to its solid features and reliability.

What Is a NOT NULL Constraint in SQL?

SQL has several ways of dealing with NULLs. In this article, we’ll focus on the NOT NULL constraint and other NULL-related clauses. Understand this and you’ll take an important step in your SQL growth! Before we get straight into the NOT NULL constraint, let’s quickly define what NULLs and constraints are. NULL values are a central concept in SQL databases. The idea behind a NULL value is simple: a NULL value means that we do not have a known value for that field.

Best SQL IDEs for You

Maybe you just started learning SQL. Maybe you already have some experience. Whatever your situation is, choosing the right IDE for you is another step in your development. Why IDE? IDE stands for integrated development environment. It is a software application that enables us to combine various aspects of writing a computer program. An IDE usually contains a source code editor, build automation tools, and a debugger. You might ask why you need an IDE when you have the command line available on your computer.

New SQL Course: GROUP BY Extensions in PostgreSQL

Do you want to take your knowledge of PostgreSQL to the next level? I have something for you: LearnSQL.com’s new GROUP BY Extensions in PostgreSQL course! It will help you get even more out of your data and create better reports and summaries. Fasten your seat belts and prepare to see what GROUP BY can do when it’s turbocharged. First, I have to confess something. I am not objective – I think PostgreSQL is the best and coolest SQL dialect.

What Is a NULL in SQL?

SQL uses NULLs as a special flag that signals the lack of a value for a field or a variable. NULLs should be used wisely so the database gives a faithful picture of the reality it represents. Some people associate NULLs with zeros; others think that NULL means “none”. In SQL, neither of these are true. Simply put, an SQL NULL means that we don’t have a value for that particular field.

SQL JOIN Topics That Require Practice

Are you interested in learning how to join tables in SQL? Where do you start? Many JOIN topics require practice. In this article, we’ll explore these topics by writing codes to solve real-life situations. Hopefully, you will learn which JOIN topics require attention. To make it easier for you, the topics are divided into beginner, intermediate, and advanced. Joining two or more tables in SQL lifts data analysis to another level.

Where Can I Find Good Courses to Practice MS SQL Server?

Updated on: April 6, 2024 Begin your journey to mastering MS SQL Server with the finest practice exercises out there. Whether you are a beginner or seeking to improve your T-SQL skills, explore the top destinations for the most engaging and interactive MS SQL practice courses online. You've started learning MS SQL Server. Maybe you've done a course, watched some YouTube tutorials, and feel pretty confident in your knowledge. What now?

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.

How to Get Descendants of a Parent in SQL

Want to learn how to handle family trees and find descendants of a parent? By reading this article, you’ll learn how to handle hierarchical data. Finding descendants from a parent is a common problem in SQL. If you imagine a family tree, the basic building block that forms the relationships within it is the parent-child relationship. The parent-child relationship is precisely what defines all hierarchical data. Another example of hierarchical data is the manager-employee relationship.

What Do the Operators LIKE and NOT LIKE Do?

The SQL LIKE and NOT LIKE operators are used to find matches between a string and a given pattern. They are part of standard SQL and work across all database types, making it essential knowledge for all SQL users. Gaining an understanding of these operators will allow you to write better queries and demonstrate to potential employers that you have the skills required to filter through expansive data sets.

How to JOIN Tables in SQL

Do you need to display data stored in different tables? Then it’s time to use SQL JOINs! This can be a challenging topic for beginners, so I’ve prepared this comprehensive step-by-step guide on joining tables in SQL. Often, the information that you want to display is stored in several tables. In such cases, you’ll need to join these tables by specifying which rows should be combined with other rows. That’s exactly what JOIN does.

Free SQL Course of the Month – Window Functions

Are you looking for a good SQL window functions course? What if I told you that throughout March, you could access the best window functions course in the world for absolutely FREE? You read that right: you won't pay a dime! Hurry up! Time is running out! But wait – why is LearnSQL.com giving you a free SQL course? Well, we believe sometimes you just have to be good to others.

MS SQL Server vs. PostgreSQL: Which to Choose?

Choosing the DBMS you will use for a new project is a very important and difficult decision. Two popular choices are MS SQL Server and PostgreSQL. To help you decide which would be best for you, I'll compare their features, list pros and cons, and give you some examples. Your selection of database management system (DBMS) depends on the type of business or project you're implementing. First, you need to know:

How Much SQL Practice Do You Need to Become a Pro?

Are you wondering how long it will take to learn and practice SQL before you can call yourself a pro? In this article, I will try to help you answer this question. Being a pro in SQL can mean many different things. Some people would say that being a professional is about mastery of advanced SQL, i.e. window functions or complex subqueries. For other people, being a professional means getting paid for your skills.

SQL Terms Beginners Should Know - Part 3

This is the third part of my list of essential SQL terms for beginners. In the first, you learned what tables, relational databases, and queries are. In the second part of the tutorial, I told you about aliases, SQL JOINs, primary keys, and subqueries. Now, it's time for more advanced database terms. But don't be afraid! I won’t crush you with scientific definitions. I will explain everything simply so that you can easily understand.

How to Use SQL to Filter Your Client Email Database

Looking for ways to be on friendly terms with your email database? Here's my way of using SQL to evaluate a promotion. A client database plays an essential role in developing your sales and marketing strategies. Having a clear and well-structured database has several benefits. For example, you can increase your company's revenue by managing your current and new clients – they can be monitored and offered special promotions. Moreover, such an effort develops customer satisfaction and increases value for your current customers.

Learn SQL And Start Your Journey Towards Personal Growth

Are you at the very beginning of your career and don't know what employers are looking for? Maybe you already have a lot of experience, but feel like it's time to change or update your skillset. Learning SQL can be a great choice. Read on and find out why. Regardless of your career stage, you cannot neglect your personal development. Whoever does not move forward falls behind. As you start learning new things, new opportunities will open up for you, both in your personal and professional life.

How to Practice PostgreSQL Online

PostgreSQL is hot right now!If you want to join a community of people passionate about data, this open-source database system is something you need to try. Like everything we teach on LearnSQL.com, PostgreSQL requires practice. To profit from Postgres – as this dialect is sometimes called – you need to start with the basics. You can watch some tutorials on YouTube or read articles to get to know what a Database Management System (DBMS) is.

What Is GROUP BY in SQL?

GROUP BY is a great SQL feature that allows you to perform powerful calculations on grouped data. Do you want to learn how to get powerful insights from your data? Would you like to know what GROUP BY does and when you should use it? If your answer is yes, keep reading. In this article, you will learn exactly that. Why You Need GROUP BY In today's digitized world – no matter what business you are in – database tables are usually huge, with millions of records.

6 Advanced SQL Queries for Analyzing Financial Data

Are you an advanced SQL user who’s new to finance? Do you want to learn how to use your knowledge to analyze financial data? The article will give you some guidance. You probably know that SQL is a potent tool for analyzing all sorts of data. The bigger and more complex data, the more beneficial SQL becomes. In certain situations, financial data can be very complicated; producing a sophisticated analysis requires sophisticated tools.

Enumerate and Explain All the Basic Elements of an SQL Query

“What are the basic elements of an SQL query?” is a popular SQL job interview question. In this article, we review the basic syntax of an SQL query. An SQL query, which requests information from a relational database, consists of several elements. These allow you to select specific columns from specific tables and to filter and sort this information if necessary. In this article, I’ll briefly review these elements by explaining what each element does and how to use it.

Want to Learn Advanced PostgreSQL? Try This!

Why and how should you learn advanced PostgreSQL? I’ll give you some tips that will help you achieve your goals. Keeping up with technology is hard; anyone who has foolishly tried to do so can confirm this (me, for example!). Most of the time, it just doesn't work. And to be brutally honest, keeping up with all the technologies all the time is pointless. You shouldn’t know everything about everything; it’s better to know as much as you need within the technology you use or want to use.

What Does ORDER BY Do?

When analyzing data, it often helps to have rows ordered in a specific way. In this article, I’ll use multiple examples to show how SQL ORDER BY sorts data according to one or more columns in ascending or descending order. Introduction to ORDER BY By default, the order of rows in the output of an SQL query is arbitrary. If you want to sort the output in a particular order, you’ll need to use the ORDER BY keyword.

How to Import CSVs to PostgreSQL Using PgAdmin

Do you work with data and use CSV files? Here is a practical guide on how to import such files into a PostgreSQL database using pgAdmin, one of the best PostgreSQL editors on the market. Let's get right into importing CSVs into a Postgres database. We’ll start by explaining what a CSV file is, then we’ll introduce you to pgAdmin and show you how to do the import process. Don’t worry – it’s easy!

What Is a Unique Constraint in SQL?

To ensure the uniqueness of data in a database, we use the SQL UNIQUE constraint. In this article, we’ll discuss how, when, and why to implement it. The idea of a unique constraint is not unique to SQL; it’s a familiar concept in real life, although we probably call it something else! For example, think of ID numbers. There can be only one social security number (SSN) per person and each one must be unique.

How Much SQL Do I Need to Know?

Learning a new skill or starting a new profession can be a real challenge, especially when you’re unsure of how much you really need to know before taking the plunge. Imposter syndrome is also a real thing – how could you possibly catch up with all those SQL ‘experts’ who seem like they’ve been doing this since they were in diapers? The good news is you can learn SQL quickly and easily, and you don’t need to know nearly as much as you think you do.

SQL Course of the Month – SQL JOINs

If you want to really learn SQL, you can’t skip SQL JOINs. They are some of the most fundamental and commonly used features of the SQL language. That’s why SQL JOINs is our February SQL Course of the Month. What makes SQL JOINs so important? I asked Agnieszka Kozubek-Krycuń, Vertabelo's Chief Content Officer, about it. Here's what she said. Is it true that SQL JOINs are one of the foundations of SQL?

Data Types in SQL

Read this article and learn the ABC of SQL data types. Data types are used to define the type of data stored in a database. However, there are related concepts that a good SQL developer should know: data type conversion, what operations are possible between different data types, date arithmetic, etc. SQL also provides functions that manipulate values of different data types (i.e. functions for string data, date and time data, etc.

Using AND, OR, and NOT Operators in SQL

AND, OR, and NOT are important logical operators in SQL. They help you combine the conditions used to filter records. They are most commonly used in conjunction with the WHERE or HAVING clauses. Furthermore, this topic is a pretty common SQL job interview question. To help you completely understand these operators, I’ll take you through some examples, fully explaining the syntax and purpose of each. Practicing using examples like these is one of the best methods for learning SQL.

Why Aren’t SQL Window Functions Allowed in GROUP BY?

It’s true – the SQL order of operations means window functions aren’t allowed in GROUP BY. But you can use them anyway with this special trick. SQL window functions are one of the language’s most powerful features. However, the syntax of window functions is not easy to master. It has lots of details that can cause beginners to stumble. One of the most common traps is trying to use window functions in GROUP BY.

7 Common GROUP BY Errors

Are you making these errors with GROUP BY in SQL? Find out what they are, how to avoid them, and how to fix them. SQL’s GROUP BY statement can quickly uncover powerful data insights. At first, using GROUP BY can seem easy – e.g. when creating basic SQL reports that you’ll present to business decision-makers. But while learning this powerful feature, you could become trapped in weird errors or get incorrect results caused by improperly written GROUP BY statements.

How to Create a Table with a Foreign Key in SQL

Problem: You want to create a foreign key for a table in a database. Example: We would like to create a table named student that contains a foreign key that refers to the id column in the table city. Solution 1: Creating new table with single-column foreign key CREATE TABLE student ( id INT PRIMARY KEY, first_name VARCHAR(100) NOT NULL, last_name VARCHAR(100) NOT NULL, city_id INT FOREIGN KEY REFERENCES city(id) ); Discussion: To create a new table containing a foreign key column that references another table, use the keyword FOREIGN KEY REFERENCES at the end of the definition of that column.

How to Delete a Foreign Key Constraint in SQL

Problem: You want to delete a foreign key from a table in a database. Example: We want to remove the foreign key named fk_student_city_id from the table student. Solution: ALTER TABLE student DROP CONSTRAINT fk_student_city_id; Discussion: To delete a foreign key from a table, use the ALTER TABLE clause with the name of the table (in our example, student) followed by the clause DROP CONSTRAINT with the name of the foreign key constraint.

Why Learn SQL Window Functions in 2021?

SQL window functions provide some extremely powerful and convenient features for data practitioners. This article explains why you should learn window functions and when you should use them. I’ll also provide some examples to help you visualize the concepts. Window functions are part of advanced modern SQL – knowledge of which will definitely enrich the repertoire of any SQL user. Window functions have a broad range of uses and can be applied to almost all facets of business.

Where Can I Find Good SQL CTE Exercises?

Find the top online resources for SQL Common Table Expression (CTE) exercises! CTEs allow you to structure and organize SQL queries efficiently, which is essential if you want to advance your SQL knowledge. A Common Table Expression, or CTE, is a SQL syntax that creates a temporary data set. This set contains separate data than the main query, which can typically be referenced or reused in a subsequent query. A CTE is considered temporary because the result is not permanently stored anywhere and only exists for the duration of the query.

Stories of the LearnSQL Scholarship Program

2020 is behind us. It was an extremely difficult year: We’ve struggled with the Covid-19 pandemic, a worldwide economic crisis, and constant anxiety. Many people have lost their jobs and their prospects for a better tomorrow. That's why we decided to do something positive: establishing a SQL scholarship program. We decided to find people in difficult situations and try to help them. For many, learning SQL can be their chance to get a job and develop their career.

What Is the SQL WHERE Clause?

The WHERE clause is a fundamental part of SQL. This clause filters results and applies conditions to SQL queries. It is most commonly used alongside the SELECT statement. If you’re a complete newcomer to this topic, you can learn the basics of SQL, including WHERE, in our SQL Basics course This article will clearly explain how to use WHERE in a SQL query. After reading it, you’ll have the confidence and knowledge to integrate WHERE into your daily work.

Monthly SQL Challenges in 2021

Did you know that LearnSQL.com provides a monthly SQL Challenge? Every month, we publish a new set of SQL practice exercises. Find out what to expect from our SQL challenges in 2021. Here at LearnSQL.com, we believe that the best way to learn SQL is through practice. After all, writing SQL is a practical skill. That’s why all our SQL courses (and there are over 30 of them!) are interactive: You learn SQL by writing SQL code.

What’s the Difference Between SQL CTEs and Views?

SQL views vs. CTEs: What do they do? How are they different? Which one should you use and when? Get your answers here! In SQL, both CTEs (common table expressions) and views help organize your queries, leading to cleaner and easier-to-follow code. However, there are some important differences between them. This article will walk you through several examples of CTEs and views and explain when to use each one.

What Is LEFT JOIN in SQL?

Get to know the details of LEFT JOIN, one of the most common SQL JOIN types. SQL is mainly about getting data from databases. Very often, you’ll need data to be combined from multiple tables in your database. That’s when JOINs come into play. LEFT JOIN is one of the JOIN types that you are likely to use very often. In this article, I’ll explain the syntax of LEFT JOIN and how it works using several examples and illustrations.

Best SQL Video Tutorials for 2021

Ready for this year’s picks for the best YouTube SQL video tutorials? Here are our top 5 choices! It's been well over a year since I last wrote about SQL tutorials on YouTube. Those seven channels can help you learn the basics of SQL quite painlessly, but now it's time to add to that list with 2021’s top contenders. Which YouTube SQL tutorials are worth your time and attention? I’ve got my favorites, but first, let’s consider an important question:

What Is Auto-Increment in SQL?

In this article, we’ll learn the basics of the auto-increment feature of SQL: what it is and how to use it efficiently. One of the many features offered by SQL is auto-increment. It allows us to automatically generate values in a numeric column upon row insertion. You could think of it as an automatically supplied default value – the next number in a number sequence – that’s generated when the row is inserted.

Winter 2021 Track of the Season: Creating Database Structure

New year, new challenges, and ... a new SQL Track of the Season! Start 2021 by learning SQL and data engineering. In this article, we answer frequently asked questions about our Creating Database Structure track. Maybe you haven't noticed yet that there’s an order to many LearnSQL.com courses; you can learn SQL by doing them in the right order. We call this option our ‘SQL tracks’. These are logically structured and well-thought-out learning paths that will help you take the next steps towards becoming an SQL expert.

SQL Course of the Month – Standard SQL Functions

Are you dreaming of becoming a data analyst? Or maybe you just want to work effectively with your company’s databases? You can – with SQL functions. We’ve selected Standard SQL Functions to be our January 2021 SQL Course of the Month. What will you find inside? I asked Agnieszka Kozubek-Krycuń, Vertabelo's Chief Content Officer, about it. Here's what she said. What are SQL functions? The term reminds me of SELECT or JOIN.

SQL JOIN Tips for Beginners

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.

Why Learn SQL This New Year?

In answering this question, we’ll take a look at the idea behind New Year’s resolutions, explore what SQL is, and see why learning it should be your goal for 2021. We’ve all heard of New Year’s resolutions, and we all have personal experience of how difficult it can be to see them through to a successful conclusion. We’ll examine the history of New Year’s resolutions, why they often fail, and how to ensure your resolution for learning SQL in 2021 doesn’t meet with the same fate as so many others that never made it past the end of January.

How to Make a Column Unique in SQL?

Problem: You would like to make a column unique in a given table in a database. Example: We would like to make the column name unique in the table product. The query below presents one way to do it. Solution 1: Creating new table with a UNIQUE constraint CREATE TABLE product ( id INT NOT NULL PRIMARY KEY, name VARCHAR(100) UNIQUE, producer VARCHAR(100), category VARCHAR(100) ); Discussion: In this example a given column (the column name) was made unique by adding the clause UNIQUE at the end of the column definition (name VARCHAR(100) UNIQUE).

How to remove a unique constraint in SQL?

Problem: You would like to remove a unique constraint from the column/columns in a table in a database. Example: We would like to drop the unique constraint in the table product from the column name. The statement below shows how to do it. Solution ALTER TABLE product DROP CONSTRAINT UQ_product_name In this example the table product is altered by using the ALTER TABLE clause. After this clause you enter the name of the table (in our example: product) and the clause DROP CONSTRAINT with the name of the unique constraint you want to remove.

2020’s Best LearnSQL.com Articles

We published a whole lot of interesting SQL articles this year. I had a difficult task – choosing the best LearnSQL.com articles of 2020. And here they are. The crazy year of 2020 is coming to an end. How will we remember it? Probably by the COVID-19 pandemic; we stayed home and fought the virus. It was a difficult time. However, many of us did not give up and kept trying to achieve our professional goals.

What Is a Database Index?

Database indexes are critical to query speed and efficiency. Learn when, why, and how to use them – and when not to – in this post. Indexes are very important database objects; they optimize data access and improve database performance by helping the database execute SQL queries faster. Why not take this opportunity to learn how indexes work and how to create them? What Is a Database Index? Indexes are data structures that can increase a database’s efficiency in accessing tables.

What Is an SQL INNER JOIN?

How do you combine data from different tables in one query? An SQL feature called JOIN is the most common operator used to create complex queries. Learn the basics in this article. SQL allows us to select data from more than one table. In fact, the whole idea of using relational databases is selecting data from related tables. And we can use SQL’s JOIN operator to do this. There are many types of JOINs in SQL.

SQL Window Functions for Managers: Who Gets a Raise?

Window functions are one of the most powerful features in modern SQL. In this article, you will learn why window functions are so great. I will list you the most useful window functions and briefly explain when and how you can use them. Simple SELECT statements, in combination with WHERE, GROUP BY, and HAVING, are sufficient for many analyses at work. I used standard SQL for many years before I realized there is something more.

The Best SQL Lectures on YouTube

YouTube contains a vast amount of information. The trick is to know how to find what’s valuable. If you type “SQL lectures” in the YouTube search engine, you will probably get a list of boring or unhelpful clips. However, there are hidden gems, and I’ve compiled a list of the best SQL talks I’ve found on YouTube so far. First, let's establish one thing. I didn't choose any YouTube SQL tutorials when making this list.

Best Online Courses for SQL Window Functions

In this article, I will summarize the top online tutorials and courses available on SQL window functions for enthusiasts of data analysis, data science, and data engineering. The information is here to help you embrace the topic with ease and feel comfortable using window functions in SQL databases. SQL window functions can help you solve some of the most common analysis challenges in business: What are the N most popular products for each month of the year?

How to Use CASE WHEN With SUM() in SQL

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. The best way to learn about CASE WHEN and how to use it with SUM() is our hands-on course Creating Basic SQL Reports. It contains over 90 interactive exercises that will teach you different techniques how to create complex reports in SQL.

SQL Scholarship Program 2020

2020 is slowly coming to an end. It was extremely difficult for everyone. We’ve therefore decided to end it with something positive. This Holiday, we want to help someone change their life. Learn SQL will fund 50 SQL Scholarships for people who cannot afford to learn SQL and who may find it helpful in a difficult situation. We’ll hand out our flagship track - SQL From A to Z - for FREE!

What is an SQL View?

A view is a well-known feature in SQL. It allows you to create a virtual table based on an SQL query referring to other tables in the database. A view stores an SQL query that is executed whenever you refer to the view. This is a convenient way to get the desired data because it is easier to run a query stored in a view than to type a query from scratch.

Practicing SQL for Your First Day of Work

Your new SQL job is likely to surprise you in many ways. To minimize the risk of getting lost in the jungle of data, I recommend you get some additional SQL practice before your first day. There are special SQL practice sets and projects on the internet to help you prepare. You’ll also get help from your colleagues, as programmers are usually open and supportive. If you’re reading this, you’ve probably heard about the opportunities SQL and data science offer.

The Top 10 SQL JOIN Interview Questions with Answers

Have you ever wondered what SQL JOIN questions you might be asked in an interview? Do you feel prepared to answer them? This article covers the most common SQL JOIN interview questions and how to answer them. If you are applying for a job as a data analyst or software developer, you will likely be asked about your SQL JOIN knowledge. SQL JOIN clauses are a great topic for interviewers to quiz you on.

The History of SQL Standards

Has the SQL standard changed in the 30+ years it's been around? Absolutely! Learn about the journey from SQL-86 to modern SQL, today’s standard data language. SQL was created in the early 1970s by IBM. In 1974, Donald Chamberlin and Raymond Boyce published the article SEQUEL: A Structured English Query Language, which introduced SQL to the world. The article contained the BNF grammar (a detailed technical description of the language syntax) for the language, which IBM later thought was a mistake.

SQL Terms Beginners Should Know – Part 2

This is the second part of my list of essential SQL terms for beginners. In the first, you learned what a table, relational database, and query are. Now, it's time for more advanced database terms. But don't be afraid! I won’t crush you with scientific definitions. I will explain everything simply so that you can easily understand. If you want to review the basic SQL terms, see my previous article, SQL Terms Beginners Should Know.

How Do You Write a SELECT Statement in SQL?

SQL is a language to communicate with relational databases, and the SELECT statement is the first thing you’ll learn when you start using SQL. In this article, you’ll learn how to write SELECT statements, from the basics to more advanced. What Is SQL? SQL stands for “Structured Query Language.” It has a long history that started in the 1970s. Being the standard for communication with relational databases, it has maintained its popularity.

SQL Technologies Are More Common Than You Think

Where is SQL being used today? The answers might surprise you! (Hint: SQL technology is basically everywhere.) Is it worth learning SQL? After all, the language was created in the 1970s. Is it still relevant today? The list of technologies that support SQL is very long – and it’s growing. Read on to find out what kinds of programs use SQL. SQL in Databases Relational Databases = SQL Databases It’s no surprise that SQL is used in relational databases.

SQL Course of the Month – Customer Behavior Analysis in SQL

Do you run a business? Do you want to squeeze even more out of your data? Start by analyzing your customers' behavior using SQL! Throughout December, you can learn how to do it for free on LearnSQL.com! I asked Agnieszka Kozubek-Krycuń, Vertabelo's Chief Content Officer, about our December Course of the Month, Customer Behavior Analysis in SQL. Here's what she told me. Let's start with the basics: Why analyze customer behavior?

What Is a Foreign Key in SQL?

What does a foreign key do in SQL? Why would you need one? Learn the ABCs of foreign keys in five minutes. Foreign keys are a central concept in SQL databases; they allow us to enforce data consistency. Usually they work with primary keys to connect two database tables, like a virtual bridge. All SQL developers need to know what SQL foreign keys are, how they work, what data values are allowed in them, and how they’re created.

Aggregate Functions vs Window Functions: A Comparison

If you aren’t familiar with SQL’s window functions, you may wonder how they differ from aggregate functions. When should you use window functions? In this article, we’ll review window functions and aggregate functions, examine their similarities and differences, and see which one to choose depending on what you need to do. After you’ve tackled basic SQL, you’ll probably want to get into some of its more advanced functions. That’s great; these functions make reporting and analysis easier.

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?

SQL in the Open-Source World

Did you know there are free, open-source databases that use SQL? In this article, I'll show you which open-source database solutions can meet your needs. Ever wonder why many people still use paid programs when the same things can be done with free options? Personally, I am an avid supporter of the open-source movement. For years, I have been trying to apply and promote such solutions and support an active community around them.

How To Learn The SELECT Statement in SQL

When you think about learning SQL, one of the first things you come across is the SELECT statement. Selecting information is arguably the most important SQL feature. In this article, we’ll demonstrate the typical use cases for SQL SELECT with practical examples. Read this article if you’re a beginner database user and would like to know what SELECT can do for you. SQL, or Structured Query Language, is the programming language the IT world uses to communicate with databases.

What Is a SQL Constraint?

What are SQL constraints? When and why should you use them? We give examples of common constraints and demonstrate how to apply them. When you’re creating a relational database, you often want to impose certain restrictions on some columns. For example, a column containing a social security number should store only unique values; a column containing a date of birth should not be null, or left empty. These conditions can be ensured by using SQL constraints.

The History of SQL – How It All Began

Who created SQL and why? Find out in this article! Are you learning SQL? Or are you about to take the first step towards working with databases? Great decision! Either way, it's worth knowing the history of SQL – where it came from, who came up with it, and why. Here’s a brief history of SQL, starting with its foundational concept: the database. Ted Codd and the Relational Data Model The first computer databases appeared in the late 1960s.

Practice SQL Before Interviewing a Potential Employee

Has your company grown to the point that you need to hire an SQL expert? Have you found a candidate for the job? How do you prepare for the interview, especially if you don’t know SQL? Don't worry! Follow our suggestions on how to practice SQL. We have tips and tricks to help you feel confident and find the perfect employee. Who You Want To Hire First of all, you need to know the requirements for the new employee.

SQL JOIN Types Explained

What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN in SQL? When should you use each one? We’ve got your answers right here. You want to combine data from two or more different tables, but you’re not sure how to do it in SQL. No worries. In this article, I will show you how to use the SQL JOIN clause to merge data from two tables.

Top 7 Online Courses for Data Engineers

This article summarizes the top online courses available for data engineers. We have picks suitable for beginners as well as intermediate learners. If you’re interested in database design and management, check these courses out! Most individuals who aspire to enter the realm of data aim for data scientist or data analyst roles. While these roles are indeed very rewarding because of their tangible links to customers and business direction, the role of data engineers is equally vital for businesses that operate in a data-rich environment.

SQL Terms Beginners Should Know

Have you started learning SQL? Do you feel a little lost in the maze of new words and ideas? Here’s a list of 10 absolutely essential SQL terms for beginners. When you start learning SQL, there’s a lot to process. And some of it – even basic SQL terms – gets lost in the shuffle. If this sounds like you, bookmark this article; it will be a handy reference.

Where to Go After Learning SQL Basics

Learning to code is – in general – a lot of fun, for sure. Even after a few years in the IT industry, I still love learning new technologies. And I now know that learning with a good plan is even better than learning without one. This also applies to learning with advanced SQL courses. In this article, I'll show you how learning paths can save you some time and a lot of frustration.

How to Calculate a Square in SQL

Problem: You want to find the square of a number in SQL. Example: You want to compute the square of each number in the column number from the table data. number 3 1 0.5 0 -2 Solution 1: Use SQUARE function SELECT number, SQUARE(number) AS square FROM data; Solution 2: Use multiplication operator * SELECT number, number * number AS square FROM data; Solution 3: Use POWER function SELECT number, POWER(number, 2) AS square FROM data; The result is:

How to Compute an Absolute Value in SQL

Problem: You want to find the absolute value of a number in SQL. Example: You want to compute the absolute value of each number in the column numbers from the table data. numbers -3.2 0 20 Solution: SELECT ABS(numbers) AS absolute_values FROM data; The result is: absolute_values 3.

How to Create a Primary Key in SQL

Problem: You want to create a primary key for a table in a database. Example: We want a primary key for a table called product. Solution 1: Creating new table with a single-column primary key CREATE TABLE product ( id INT PRIMARY KEY, name VARCHAR(100) NOT NULL, producer VARCHAR(100) NOT NULL, price DECIMAL(7,2) ); Discussion: To create a new table with a column defined as the primary key, you can use the keyword PRIMARY KEY at the end of the definition of that column.

How to Get a Remainder Using MOD() in PostgreSQL, MS SQL Server, and MySQL

Problem: You want to find the (non-negative) remainder. Example: In the table numbers, you have two columns of integers: a and b. ab 93 53 23 03 -23 -53 -93 5-3 -5-3 50 00 You want to compute the remainders from dividing a by b.

How to Remove a Primary Key in SQL

Problem: You want to drop a primary key from a table in a database. Example: We want to remove the primary key from the table product. Solution 1: ALTER TABLE product DROP PRIMARY KEY; Discussion: To drop a primary key from a table, use an ALTER TABLE clause with the name of the table (in our example, product) followed by the clause DROP PRIMARY KEY. Since a table can have only one primary key, you don’t need to specify the primary key column(s).

Kickstart SQL Learning with Our SQL Basics Course

Updated on: February 19, 2024 Why learn SQL from our interactive online courses? Two reasons: 1) Power up your career. 2) Avoid being a noob. What does it mean to be a noob? “Noob” comes to us from the world of computer games. It’s a combination of “newbie” and “beginner”. It’s not a very nice word. It means that someone has found you an inexperienced player and (even worse) resistant to learning.

SQL Course of the Month – GROUP BY Extensions in SQL

Do you want to develop your SQL skills? Do you want to get more out of your data and prepare better reports and summaries? The answer is learning to use SQL’s GROUP BY extensions. But how should you go about this? I asked the same question to Agnieszka Kozubek-Krycuń, Vertabelo’s Chief Content Officer. As she explains, the secret is in this November’s free SQL Course of the Month: GROUP BY Extensions in SQL.

What is the Difference Between COUNT(*), COUNT(1), COUNT(column), and COUNT(DISTINCT)?

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.

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.

How to Fix a 'Not a GROUP BY Expression' Error

Whether you are an experienced SQL user or only a beginner, your SQL queries may return errors. The accompanying messages are supposed to help you fix them; however, sometimes the messages are not very helpful. The Oracle message “Not a GROUP BY expression” is one such example. Let’s review what this is about and how to fix it. We are going to assume some basic understanding of how GROUP BY works.

How to Learn SQL Common Table Expressions (CTEs)

Common table expressions are very useful for organizing, traversing, and improving the readability of long SQL queries.  Moreover, recursive CTEs, which can reference themselves, solve problems that cannot be addressed with other queries. But how do you master common table expressions in SQL? In this article, I discuss the most effective strategies for learning CTEs and suggest how to address the common challenges of learning common table expressions on your own.

What is a Primary Key in SQL?

Primary keys are an important concept in SQL databases. They provide a unique ID for every row in a database table. As an SQL developer, you should know what primary keys are, what data values are allowed in them, and how to create them. Read this article to learn the ABCs of primary keys in 10 minutes. How to Identify Rows in a Table Tables are the main objects in an SQL database, and as you probably know, tables store records or rows.

Is Learning SQL for Free Worthwhile?

Everyone likes to get something for free, even when it comes to SQL courses. But is free always good? Find out how and where you can learn SQL for free – in a way that’s worth your time. Beginner-friendly database courses and SQL tutorials often promise to teach SQL fundamentals like SELECT, WHERE, GROUP BY, HAVING, and ORDER BY. These commands are the basis of a powerful set of skills for entry-level jobs in data analysis or databases.

What Is a DBMS?

Updated on: February 19, 2024 We generate vast quantities of data every day, and that data needs to be stored somehow. That’s where DBMSs come in handy. Find out what they are and how they relate to databases. If you go on a diet and simply want to keep track of your weight, you can probably use a piece of paper and a pencil. If you then want to chart your daily caloric intake, you’ll probably switch to something like a computer spreadsheet.

Google Analytics and SQL

Google Analytics is a very popular tool among website and blog owners alike. With a simple and quick setup, it lets you gather data about your web page visitors easily. However, did you know that you can export data from Google Analytics to create your own SQL reports? Read this article to find out how. Google Analytics is an extremely popular and powerful solution that lets you collect and analyze various kinds of information about your website.

How to Boost Your Company With SQL Courses

SQL has the power to supercharge the capabilities and performance of your entire company. But if you don’t dip your toes in the water and give some SQL courses a go, you’ll never realize the vast potential of the language. SQL, or Structured Query Language, is your ticket to expanding the scope and the results of your business or organization, no matter what sector you operate in. Whether you’re the owner or manager of your company or simply an employee interested in improving operations, learning SQL is undoubtedly, unquestionably, for you.

What Is a Self Join in SQL? Explaned With 7 Examples

The self join is a popular special case of the SQL JOIN. While most JOINs link two or more tables with each other to present their data together, a self join links a table to itself. This is usually done by joining a table to itself just once within a SQL query, but it is possible to do so multiple times within the same query. Typically, each table in a database stores a specific type of information.

How to Create One Table From Another Table in SQL

Problem: You would like to create a new table with data copied from another table. Example: Our database has a table named product with data in the following columns: id (primary key), name, category, and price. idnamecategoryprice 105roseflower5.70 108deskfurniture120.00 115tulipflower6.50 123sunflowerflower7.50 145guitarmusic300.00 155orchidflower9.50 158flutemusic156.00 In the database, let’s create a new table named florist which will store the following columns: id, name, and price.

How to Create a Table from an SQL Query

Problem: You would like to create a new table in a database with data defined by an SQL query. Example: We would like to create the table gamer based on an SQL query. In this query, we select data from another table named championship presented below. idgamerscorechampionship_date 1alice142020-08-10 2supervisor102020-09-28 3happyman02020-08-10 4lukas62020-08-10 5oli122020-08-10 6biggamer72020-09-12 In the database, let’s create a new table named gamer which will store data in all of the columns defined in the table championship (id, gamer, score, and championship_date).

How to Join the Same Table Twice

JOIN is one of the most common statements in SQL. As you may know, it is used to join and combine data from two or more tables into one common data set. In this article, I’m going to discuss special types of joins? in which you combine the same table twice—including joining a table to itself, also known as the self join. When and why do you need to do this?

How to Select the First Row in Each GROUP BY Group

Problem: You've grouped your data with GROUP BY and would like to display only the first row from each group. Example: Our database has a table named exam_results with data in the following table: first_namelast_nameyearresult JohnKlein202040 EdithBlack202043 MarkJohnson201932 LauraSummer202035 KateSmith201941 JacobBlack201944 TomBennett202038 EmilyKelly202043 For each year, let's find the student with the best result.

5 Best Online SQL Courses for Business Analysts

Why bother to learn via an online SQL course? SQL is pure profit – it allows analysts to interpret data efficiently and companies to adopt better strategies. In this post, we’ll look at our top 5 SQL courses for business analysts. Being into finance, economics, and IT systems has brought you to business analysis. It’s a fascinating combination of skills; you’re combining business and technology, which makes you a valuable asset to your company.

How to Create Your First Table in SQL

Creating a database table with SQL is one of the core skills you’ll need to work with data. And it’s easy to learn, so let’s get started! Imagine you’re analyzing data and want to store your results in a database table. Sure, you've done this a million times in Excel. But you’re not sure how to create a table with SQL. Or maybe you’ve noticed that data engineering is in high demand and you want to start learning its core concepts.

Five Essential Features of a Good SQL Course

There are many different platforms offering SQL courses. If you’re a beginner, it may be difficult to choose the right one for you. Find out what we think are the essential features of a good SQL course. Remember, if you make a poor choice at the beginning, you may get discouraged or get into bad habits that will impact your work down the line. What Is SQL? SQL, or Structured Query Language, is a programming language you use to talk to databases.

A Comprehensive Introduction to Window Functions in MySQL

Do a deep dive into the working principles, syntax, and applications of various MySQL window functions. There are many open source databases you could choose; MySQL is consistently one of the most popular. But until 2018, there was no provision for including window functions in MySQL. Fortunately, all that has changed – starting from MySQL 8.0, SQL window functions were now available to MySQL users. Please note that window functions are available only in MySQL 8.

SQL Course of the Month: INSERT, UPDATE, DELETE Data

So, you've started learning SQL, and you already know what the SELECT command is and when to use it! Congratulations! Now, it's time to take the next step towards becoming an expert. You need to know the SQL UPDATE, INSERT, and DELETE commands to modify data in your tables. These are the basics that will allow you to work with tables. But what's the best way to learn them? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo.

How Will Learning SQL Make You a Better Boss?

Updated on: April 6, 2024 Looking to enhance the performance of your team, elevate your own productivity, or boost the efficiency of your entire department or company? Consider learning SQL! Why? Because its benefits are substantial and the return on investment is significant. What does learning SQL and being a better boss have to do with each other? Being a better manager can make your employees happier while growing your business.

Six Window Function Templates to Save in Your Code Editor

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.

New Course: Customer Behavior Analysis in SQL

Good news! A new SQL course is here! We’re happy to announce the release of our Customer Behavior Analysis in SQL course. Do you want to get to know your clients and better understand their needs and behavior? If so, this great interactive SQL course is for you. Discover the power of full customer lifecycle analytics in SQL and know more than your competitors. The LearnSQL.com team is happy to announce the release of a new SQL course on our platform: Customer Behavior Analysis in SQL.

SQL Basics Cheat Sheet

Download this 2-page SQL Basics Cheat Sheet in PDF or PNG format, print it out, and stick to your desk. The SQL Basics Cheat Sheet provides you with the syntax of all basics clauses, shows you how to write different conditions, and has examples. You can download this cheat sheet as follows: Download 2-page SQL Basics Cheat Sheet in PDF format (A4) Download 2-page SQL Basics Cheat Sheet in PDF format (Letter) Download 1-page SQL Basics Cheat Sheet in PDF format (A3) Download 1-page SQL Basics Cheat Sheet in PDF format (Ledger) Download SQL Basics Cheat Sheet in mobile-friendly PDF You may also read the contents here:

What Is the MySQL OVER Clause?

If you want to learn window functions in MySQL, you need to understand the OVER clause. In this article, we use real-world examples to explain what the MySQL OVER clause is, how it works, and why it’s so awesome. In 2018, MySQL introduced a new feature: window functions, which are accessed via the OVER clause. Window functions are a super powerful resource available in almost all SQL databases. They perform a specific calculation (e.

SQL Means Business - The Way of an Engineer

Have you been wondering why some companies fail and others achieve success? It's not a matter of luck but of the right people. Łukasz Kubicki at Vertabelo deals with business and product development. I asked him how he started his adventure with programming, how an engineer got into business, and if he liked playing computer games. Here's what he said. If you were to write one sentence about yourself, what would it be?

Did You Know LearnSQL.com Has Free SQL Courses?

Who doesn't like getting something for free? Each month, we give LearnSQL.com users a bit of help in their learning journey – a free, fully interactive SQL course. Since April, we have been giving our users the opportunity to learn SQL for free. Each month, we choose one of our SQL courses and give you full access to it for that month – completely free of charge! Cool, right?

How Much Do Data Engineers Earn in 2020?

Data engineering is a hot job right now. What does a data engineer do? And just how much do they earn? We’ve done the research for you. If you are reading this, you’re either starting to learn SQL or you already know some and feel it’s time to look around for a SQL job. Maybe you’re in the midst of tackling our Creating Database Structure track. And, let’s be honest, maybe you need some extra motivation to keep on you track.

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.

How to Join Two Tables in SQL

Querying data from multiple tables is very common when working with relational databases. It is not difficult if you know how to use the dedicated SQL operators for doing this. In this article, you will learn how to join two tables by using WHERE and by using a special operator JOIN, and you will see how to filter rows in the result set. If you want to practice joining tables in SQL, check out our interactive SQL JOINs course.

GROUP BY in SQL Explained

The SQL GROUP BY statement is easy to use, but it can be hard to master. Learn what you can do with GROUP BY, how it works, and how to use it with aggregate functions. GROUP BY is one of the basic SQL tools. However, it might be difficult for beginners to understand how GROUP BY works and how it is used to compute statistics with different aggregate functions. In this article, I’ll use several examples to show exactly how GROUP BY organizes rows and how aggregate functions can be used to calculate statistics on one or more columns.

Top 5 Beginner Online SQL Courses in 2020

Looking for an exciting new career? Data analysis won’t disappoint you! The simplest way to make this possible is by learning SQL, and online SQL courses are the most effective learning method. Don’t know where to start? Here’s an overview of the best online SQL courses for complete beginners. There are infinite reasons for changing your industry. You may want to land a new job because you’re burnt out. You may be bored and want something more challenging.

Creating SQL Courses: Behind the Scenes at LearnSQL.com

Take a peek behind the scenes and learn our secret for creating great SQL courses! Have you ever wondered how LearnSQL.com courses are created? Are we looking at a lot of hard work or just a bit of magic? Or maybe both? Here’s a hint: we rely on proven methods to create user-friendly online courses. But it’s not easy! Read on to see the 8 steps we take when creating a new SQL course.

Why and How to Find Freelance SQL Jobs

If Covid-19 has you all “I-want-to-stop-working-for-the-man-and-enjoy-a-more-fulfilling-life-as-the-master-of-my-own-destiny”, then I’ve got news for you. Not only is it possible to be an SQL freelancer, it’s also a potentially lucrative and liberating career move. It will allow you to work for a diverse range of clients and march to the beat of your own drum. Of course, SQL freelancing isn’t for everyone. You will need a strong sense of self-motivation, some serious hustling skills, and the ability to sell yourself and your services as THE ABSOLUTE BEST all the time, every time - day in, day out.

Six Examples Using MySQL Window Functions

Window functions are an advanced SQL feature available in most popular databases. MySQL had not supported them for a long time, but that changed in Version 8.0. They are helpful not only for analysts and people who create reports, but also for other professionals who use databases to select data needed. In this article, we explain the syntax of some popular window functions with practical examples. What Is a Window Function?

What a Moving Average Is and How to Compute it in SQL

Want to dive deep into time series data and examine long-term trends? Want to know what a moving average is and how to compute it in SQL? Then this article is for you. I’ll explain a powerful feature in SQL called window functions and show how you can calculate moving averages using them. The best way to learn about SQL window functions is the interactive Window Functions course at LearnSQL.

Fall 2020 Track of the Season: SQL from A to Z

During Fall 2020, our main SQL track, SQL from A to Z, will be in the spotlight. In this article, we answer the most frequently asked questions about this track. At LearnSQL.com, our SQL courses are organized into tracks. A track is a sequence of courses designed to help you achieve a specific learning goal. The courses in the track are in a recommended order that progresses from the easiest to the most challenging.

How to Find Duplicate Values in SQL — The Ultimate Guide

Updated on: November 28th, 2023 Find duplicate values in SQL efficiently and avoid wasting resources. This article demonstrates how to locate and address duplicate records using SQL's GROUP BY and HAVING clauses. Database best practices usually dictate having unique constraints (such as the primary key) on a table to prevent the duplication of rows when data is extracted and consolidated. However, you may find yourself working on a dataset with duplicate rows.

SQL Course of the Month – Analyzing Revenue Trends in SQL

We work hard, we learn SQL, and we develop professionally. But why? For our own satisfaction, but also for money! The knowledge of SQL will increase your income significantly. If you are proficient in SQL, you can better analyze your company's revenue. How? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo. In this article, she answers your questions about our September SQL Course of the Month: Analyzing Revenue Trends in SQL.

How CTEs Work

The SQL language offers a feature named Common Table Expressions, or CTEs. Also known as WITH clauses, CTEs are a fairly new addition to SQL. They help you break longer queries into smaller chunks, making your queries much easier to understand. Read the article to find out how to use CTEs and how they differ from traditional subqueries. Common Table Expressions (CTEs), which are essentially named subqueries, were first mentioned in the SQL standard between 1999 and 2000.

How Does SQL GROUP BY Work?

Grouping results is a powerful SQL feature that allows you to compute key statistics for a group of records. GROUP BY is one of SQL’s most powerful clauses. It allows you to see data in a new way and find key metrics (like the average, maximal, and minimal values in a group of records). Without GROUP BY, all the results we obtain are oriented to records. With GROUP BY, we can create groups of records and calculate metrics on each group.

SQL CTEs Explained with Examples

Learn how you can leverage the power of Common Table Expressions (CTEs) to improve the organization and readability of your SQL queries. The commonly used abbreviation CTE stands for Common Table Expression. To learn about SQL Common Table Expressions through practice, I recommend the interactive Recursive Queries course at LearnSQL.com. It contains over 100 hands-on exercises on simple and complex recursive CTEs. What does a CTE do? Why might you want to use one in your SQL code?

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?

Where Can I Find Free Online Data Sets to Practice SQL?

Updated on 4th Sep 2023. Diving into the world of SQL can be an exciting journey. But to truly master this language, you need to practice SQL regularly. In this article, we'll guide you through some free online data sets that will help you take your SQL practice to the next level. Let's get started! You've successfully installed your chosen RDBMS and grasped the basics of SQL. So, what's the next step?

5 Examples of GROUP BY

When you start learning SQL, you quickly come across the GROUP BY clause. Data grouping—or data aggregation—is an important concept in the world of databases. In this article, we’ll demonstrate how you can use the GROUP BY clause in practice. We’ve gathered five GROUP BY examples, from easier to more complex ones so you can see data grouping in a real-life scenario. As a bonus, you’ll also learn a bit about aggregate functions and the HAVING clause.

How to Create a Table in SQL

Creating tables in databases is a very helpful skill, and not just for software engineers or database administrators. It allows you to design or change the structure of a database and store data that’s related to each other. In this article, you’ll learn what a database table is, who creates them, and how to use the syntax of the CREATE TABLE command. What Is a Database Table? A relational database is built of various structures like tables, views, procedures, and triggers.

The Most Popular Databases in 2020

Which database solution is currently most popular? Which SQL dialect should you study? In this article, I’ll share the results of my research and my personal experience. Here are the databases that are worth learning SQL to use. First, let's answer some simple questions: Is SQL still useful? Is it worth learning? If you complete an online SQL course, will it make your work easier? The answer is YES! Why?

How to Spend Less by Mastering the Monthly Budget in SQL

Do you struggle to keep your budget under control? You must have heard about various budget planning materials available as printouts, Excel spreadsheets, or smartphone apps. In this article, we’ll show you another possibility. You’ll learn how to use databases and SQL to identify the weak points of your home budget and spend less. We all need to pay for everyday necessities such as groceries or medical appointments. With money coming in and out of our pockets, it’s easy to lose track of how much we spend and if we have any savings.

Is There any Demand for SQL Language Nowadays?

SQL is 46 years old. That’s 14 years older than I am, and at least 23 years older than the jar of pickles in my refrigerator. SQL is the still-hip granddaddy of the programming world. You know the one: non-ironic suspenders, twirled mustache, tattoo peeking out over his spotted socks. He may be old, but boy, is he fly. If you’ve heard of the NoSQL movement, you may be wondering: why learn SQL in this day and age?

5 Reasons You Might Fail to Learn SQL

Learning SQL isn’t hard, but that doesn’t mean you’ll sail through, problem-free. Here are five things that might cause unwary SQL learners to fail. For me, learning SQL wasn’t always about the joy of discovery. Learning itself is not all about curiosity and the satisfaction of succeeding. Sometimes there is a sense of failure. We’re often told it is better to focus on positives. I believe this. However, it is also crucial to find out what went wrong when we don’t succeed at something.

Learning SQL When You Work and Have a Family

Do you want to learn SQL but feel you can’t squeeze one more thing into your jam-packed life? Here are my tips on learning SQL when you work and have kids. You work full-time and have a family. Daily responsibilities overwhelm you. I’ve been there. Heck, I live there. I work from home and have a family. While I was writing this article, I was also waiting for a call on Zoom, doing the laundry, and cooking some pasta for my son’s dinner.

Can you Join two Tables Without a Common Column?

Yes, you can! The longer answer is yes, there are a few ways to combine two tables without a common column, including CROSS JOIN (Cartesian product) and UNION. The latter is technically not a join but can be handy for merging tables in SQL. In this article, I’ll guide you through the different solutions with examples. When Do you Need to Join Tables Without a Common Column? Beginners just getting started with SQL are usually introduced to standard equi joins, in which two tables are combined by a common column.

Who Should Learn SQL Window Functions?

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.

SQL Course of the Month – Recursive Queries

Recursive Queries is one of SQL’s more advanced features. You could say they divide SQL users into beginners and experts. But how do you learn recursive queries? And why do you need them, anyway? Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, is here to help. In this article, she answers your questions about our August SQL Course of the Month: Recursive Queries. Recursive queries … that sounds very serious.

The SQL HAVING Clause Explained

What is the SQL HAVING clause? Why do you need it, and where do you use it? We’ll explain HAVING in detail. HAVING is a very common clause in SQL queries. Like WHERE, it helps filter data; however, HAVING works in a different way. If you are familiar with the GROUP BY clause and have only heard about HAVING – or if you’re not familiar with HAVING at all – this article is what you need.

Using Subqueries in INSERT, UPDATE, DELETE Statements

Did you know that subqueries can also be used in UPDATE, INSERT, and DELETE statements? Subqueries in SQL are like building blocks that can be used in a variety of statements, not just SELECT. If you find subqueries useful in SELECT, read this article to find out how useful they can be in other instructions. You will be able to create much more complex and powerful SQL queries in no time!

Our 6 Favorite SQL Books

So you want to learn SQL and query databases? Great! Check out these six SQL books for an in-depth look at the language and you’ll be writing queries in no time! You take SQL courses, participate in internet discussions and forums, watch tutorials on YouTube... What else can you do to develop your skills? Sometimes it’s good to reach for old-fashioned sources of knowledge: SQL books. Which book(s) should you choose?

Who Is a Data Engineer?

A new kind of job has recently emerged in the IT world: Data Engineer. At first sight, it may seem very similar to Data Analyst or Data Scientist positions. However, our article explains all the important differences. We present the skills, tools, and everyday tasks of Data Engineers. We also explain how you can get started with this career path.   Thirty years ago, we typically used terms such as “Computer Scientist” when referring to anyone working with computers.

What's the Difference Between Multiple Tables in FROM and Using JOIN?

What’s your approach to joining tables in SQL? In this article, we discuss two approaches and explain why many SQL developers have a definite preference for JOIN. Do you prefer to list multiple tables in FROM and use WHERE to set the join conditions? Or do you use the JOIN keyword? SQL supports both, but there are significant differences between them. Let’s look at each one in detail and then discuss why JOIN is generally preferred.

How to Analyze a Time Series in SQL

Values ordered by time are called a time series. In this article, I’ll show you the most frequent patterns and teach you how to write queries for time series in SQL with the help of window functions. Maybe you’ve had the opportunity to analyze some variables where each value was associated with a time value. Such data – where values are ordered by time – is called time series data.

LearnSQL.com’s New Learning Path: Data Engineering

Calling all future data engineers! Would you like to learn to use SQL? Then our new Data Engineering Learning Path is just for you! We’re very excited to announce the release of a new learning path at LearnSQL.com: Data Engineering, published in July 2020. This is the second learning path offered in our platform. So far, we offered an analytical path, SQL Querying & Reporting, that focuses on writing queries and business reports in SQL.

Using GROUP BY in SQL

Now that you know SQL’s core commands, power up your queries with the GROUP BY clause and aggregate functions. GROUP BY is a SQL clause that arranges data into groups based on a common value (or values). It is widely used to obtain summary information for large datasets as well as for computing basic aggregate statistics. Once you have grasped SQL’s basic commands like SELECT, WHERE, and JOIN, mastering the GROUP BY clause can help you implement your SQL knowledge in real-world business intelligence scenarios.

The LAG Function and the LEAD Function in SQL

LAG() and LEAD() are positional functions. A positional function is a type of window function. If you are not familiar with when and how to use them, what the syntax of each function is, why you might want to use them, and what the differences are, read on! LAG() and LEAD() are positional functions. These are window functions and are very useful in creating reports, because they can refer to data from rows above or below the current row.

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.

How to Learn SQL Fast

Updated on 11th Oct 2023. Are you in a rush to boost your data analysis capabilities? Dive into our comprehensive guide and learn SQL fast! You work with data every day, but you've had enough of how long it takes to process your giant table in Excel. The time has come for a much better tool: SQL! But how long does it take to learn SQL? In this article, I'll show you how to learn SQL fast and become the Vin Diesel of data – how to become the "

How to Calculate the Difference Between Two Rows in SQL

Calculating the difference between two rows in SQL can be a challenging task. It is possible – and there’s more than one way to do it. In this article, I’ll explain how to use the SQL window functions LEAD() and LAG() to find the difference between two rows in the same table. The best way to learn window functions is our interactive Window Functions course. It contains over 200 hands-on exercise that will teach you all window functions concepts, from simple OVER() clause to complex topics such as combining window functions and GROUP BY clause.

What Is Data Engineering?

Data Engineering is a fairly new term in IT. And it’s getting more and more attention. You may have heard about a few similar fields like data science, Big Data, and machine learning. This article explains the difference between these concepts and shows how they can be combined to analyze vast amounts of data. When computers first appeared, their storage capacity was very limited. Do you remember floppy disks? They were popular in the late 20th century and typically offered around 1.

What Is a CTE?

After mastering statements like SELECT, DELETE, INSERT, and GROUP BY, you might search for ways to improve code maintainability, reproducibility, and readability. At that point, you will probably start learning about modern SQL concepts that were introduced in the early 2000s. One such SQL technique is the CTE? (common table expression) —?a temporary named result set. In this article, you will learn what a CTE is and how to use it to improve the maintenance and the readability of your code.

Top 10 Laptops for Learning SQL in 2020

If you want to learn SQL, you’re going to need a device that’s portable and powerful. I recommend a laptop. Here are the features you’ll need, as well as my picks for laptops to get you learning SQL in 2020! I must admit that browsing Amazon’s computer offers or entering any computer store can give you a headache. So many models, with so many options! They differ in components, workmanship, battery life, and screen size and resolution.

What Is a SQL Dialect, and Which one Should You Learn?

Updated on: September 12, 2023 SQL, standard SQL, SQL Server, MySQL, PostgreSQL, Oracle, … You’d like to learn SQL, but you feel overwhelmed with options and you don’t know where to start. We’ll explain what each of these terms mean and what this has to do with SQL dialects. Diving into the world of SQL dialects can feel like jumping into a deep pool without knowing how to swim. There's a ton of stuff to pick up!

Why Learn SQL for iOS and Android Development?

App and program development with iOS and Android is a huge and rapidly growing field in the software world. While some developers get through their careers knowing only their chosen development language, there are plenty of reasons to add SQL to that skill set. Here at LearnSQL.com, we are often asked: “why Learn SQL for iOS and Android development?” To answer that question, we’ve put together a little explanation about exactly why learning SQL makes sense for those in the app development space.

SQL Course of the Month – PostGIS

It's summer, and it's travel time ... at least it would be under normal conditions. The pandemic is still going on, but that doesn't stop us from dreaming about distant trips and visits to beautiful places. For now, most of us will have to do it on a map. Did you know that databases can store geographical data? With interactive maps, if you find a nice summer house on the internet, you can accurately track it and plan the best route there.

Listen to These 7 SQL Podcasts

Are you learning SQL online but craving more? If you're looking for a way to squeeze some sweet SQL knowledge into your day, try listening to a SQL podcast. Choose one of our picks and get ready to amp up your SQL game! If you're like me, you like to get deep into a topic. You’re practicing it whenever there’s an opportunity. Of course, It’s hard to make time. I cherish the days I’m able to sit down and just get some hands-on learning done.

How ORDER BY and NULL Work Together in SQL

Do NULL values come first or last when you use ORDER BY? Are they considered higher or lower than non-NULL values? In this article, I’ll explain how different relational databases treat NULL values when sorting output and how to change the default behavior of the ORDER BY clause. When LearnSQL users practice the ORDER BY clause in our SQL Basics course, they often ask why NULL values appear first in the output and how they can change this behavior.

How to Publish a LearnSQL.com Course Certificate on LinkedIn

LinkedIn draws both job seekers and recruiters. Showcasing your knowledge, skills, and experience on this professional networking site can lead to great opportunities. We know this well at LearnSQL.com. Have you finished one of our courses? Great! Tell your future employer about what you have learned. Here's a step-by-step how-to guide for publishing a course certificate on LinkedIn. I will show you how easy it is to publish a LearnSQL.

Comparing TRUNCATE TABLE, DELETE, and DROP TABLE in SQL

What’s the difference between truncating, deleting, and dropping a table in SQL? Find out in this article. There are a lot of ways to delete data in SQL, including the DELETE, TRUNCATE TABLE and DROP TABLE commands. Which one should you use in a given situation? In this article, you’ll learn the syntax of each command in different database engines like MySQL, PostgreSQL, SQL Server, and Oracle. And you’ll understand the DROP TABLE vs.

How to Learn the SQL Syntax

Read about what SQL is, and choose the best way for you among a wide variety of possibilities for learning SQL and remembering its syntax. What Is SQL? “SQL” stands for “Structured Query Language,” and as it sounds, it is a language dedicated to querying a relational database. In practice, it is used for creating, designing, and managing a relational database. People use SQL to: Create sets of tables and rows Modify database tables and index structures Insert, update, and delete data Retrieve information from a database for a variety of uses such as analytics Relational databases consist of a set of tables containing rows and columns of data.

A Mathematician in the World of SQL

She has a PhD in Mathematics and over 10 years’ experience teaching mathematics and computer science at the University of Warsaw. She knows SQL better than just about anyone I’ve met. Let’s get to know Agnieszka Kozubek-Krycuń, Vertabelo’s Chief Content Officer at Vertabelo. Let's go back in time. How did your adventure with math start? I’ve always enjoyed abstract concepts and problem solving. I was fascinated by variables when we learned to solve simple equations like x+2=5 in primary school.

Last-Minute Preparation Tips for a Database Class Exam

Getting to learn SQL is fun. You don’t really need to spend much time to understand some basic SQL concepts and use them fluently. If you’re a student facing your first database class exam soon, we’ve got you covered. In this article, we explain what you should focus on while learning SQL and studying for an entry-level database exam. Check your knowledge with our 10 sample questions and discover where you can find more SQL practice.

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.

Top SQL Social Media Groups & Channels to Follow

We get news, advice, and funny videos from Facebook, Twitter, and YouTube. Why not use social media to help you learn SQL? You wake up and the first thing you do is check for Facebook notifications. Do you take a photo of your breakfast and share it with friends on Instagram? Maybe you argue with someone on Twitter about which James Bond was the best? Or maybe you are recording a short TikTok video of you singing Lady Gaga?

What’s an SQL Inline Query?

Have you ever heard the term “inline query”? How are they different from subqueries and derived tables? Have you looked this up in numerous places and still don’t know the answer? Let’s embark on a journey and find out together! The first time I heard the term “inline query”, I was a little bit surprised. It doesn’t sound like one of SQL’s nuances and I thought I knew all the basic concepts.

Monthly SQL Challenges

SQL learners sometimes need challenges. Do you want to test your problem-solving skills or your knowledge of SQL? Then take our monthly SQL Challenges! We prepare them on LearnSQL.com every month. Each Challenge relates to a different interesting topic and will help you keep your SQL game sharp. In this article, you'll discover what our LearnSQL.com Monthly Challenges are and where to find them. We’ll also look at the Challenges collected in our Monthly SQL Challenge Mini Track.

Practical Examples of When to Use Non-Equi JOINs in SQL

If you think that two tables in SQL can be joined only using the common field, you will be excited to learn that there are other ways of joining. Non-equi JOINs use different kinds of comparison operators in the JOIN condition. In this article, I’ll guide you through non-equi JOIN examples to show the common use cases for this type of JOIN. Equi JOIN vs. Non-Equi JOIN How do you usually join two tables in SQL?

How to Convince Your Boss You Need SQL Training

Learning SQL is a great goal. Now, if you could only convince your boss that it’s good for the company as well as for you ... You’re aware of the benefits of adding SQL to your skill set. You believe that the rewards gained from you learning SQL will also benefit your employer – it’s not just another way for you to develop your professional profile. But how do you articulate this to your boss?

Top 5 Programming Languages to Learn Alongside SQL

If you already know or are about to learn SQL, you’re well on your way to being a sought-after database administrator, database engineer, or just a general database whizz kid! SQL is a modern, widely-used language that finds application in almost every industry. There is no shortage of jobs with SQL. But what if you want to branch out and learn another language to complement your SQL knowledge and skills?

How to Learn SQL JOINs

JOINs are one of the most fundamental and commonly used SQL commands for manipulating and querying real-world data sets. They are also one of the more challenging SQL topics to master! In this article, you’ll learn an effective strategy to learn the different types of SQL JOINs. When data is stored in a single table, we can easily retrieve rows and get all the information we need. But when businesses scale, so does their data.

What Are the Different Types of SQL Subqueries?

Subqueries can be used in many business cases. What subquery types does SQL offer? And how can you use them efficiently? In this article, I’ll guide you through different subquery types and the typical situations when they are useful. What Is an SQL Subquery? A subquery, or nested query, is a query placed within another SQL query. There are many different scenarios where you may want to include a query in the WHERE, FROM, or SELECT clauses of your main query.

Subquery vs. JOIN

One of the challenges in writing SQL queries is choosing whether to use a subquery or a JOIN. There are many situations in which a JOIN is the better solution, and there are others where a subquery is better. Let’s consider this topic in detail. Subqueries are used in complex SQL queries. Usually, there is a main outer query and one or more subqueries nested within the outer query.

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.

Is it Difficult to Learn SQL?

It’s the number one question asked by the students of SQL and those new to the IT world. Is it difficult to learn SQL? If you came here because you’ve been pondering that very same question, take some comfort in the fact that in no way are you alone. Even the idea of SQL can be intimidating to those of us without a tech background, but it doesn’t have to be that way.

Subquery vs. CTE: A SQL Primer

Have you ever wondered about the differences between a subquery and a common table expression (CTE) in SQL? The concepts seem very similar, but knowing the difference – and when to use each one – will help you write efficient and readable queries. First, we’ll explain the concepts underlying subqueries and CTEs. Then we’ll look at a few examples and finally analyze the pros and cons of each technique.

How to Number Rows in an SQL Result Set

Have you ever needed to add a sequential number to the records in the result of an SQL query? It’s not as simple as it looks! Find out how to do it correctly in this article. To number rows in a result set, you have to use an SQL window function called ROW_NUMBER(). This function assigns a sequential integer number to each result row. However, it can also be used to number records in different ways, such as by subsets.

SQL Course of the Month – Creating Basic SQL Reports

In May, we chose Creating Basic SQL Reports as our course of the month. Why? Because the basis of every successful business is making the right decisions based on proven data and good SQL reports. I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, about this. She knows SQL better than just about anyone and is probably the best person to talk about SQL Reporting. What does it mean to create SQL reports?

Major Companies Using PostgreSQL: Purposes & Examples

Which companies use the open-source relational database management system PostgreSQL? Find out … and learn why you should be a PostgreSQL user too. You know the blue elephant logo. You have heard that PostgreSQL is a very good solution. But which companies use it? Here is a list of the largest IT and business companies that use PostgreSQL (or Postgres, for short). Multinationals worth billions of dollars can't be wrong, right?

Overview of Ranking Functions in SQL

SQL ranking functions make working with relational databases easier, especially for data analysts, marketers, and financial specialists. These functions are used to assign a ranking number for each record and allow you to efficiently create useful reports. SQL ranking functions are window functions. Window functions compute the result based on a set of rows. The word “window” refers to this set of rows. Let’s look at the syntax of ranking functions:

Beginner’s Guide to the SQL Subquery

Subqueries are a powerful SQL resource, allowing us to combine data from multiple tables in a single query. In this article, we’ll teach you everything you need to begin using subqueries. Perhaps the simplest definition of a SQL subquery is “A query inside a query”. Subqueries are so easy to understand that they often appear in the opening chapters of SQL courses. However, there are many variants of subqueries that need to be explained.

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.

SQL in Google Sheets? Yes, We Can!

Did you know that you can write SQL-like queries in Google spreadsheets? This feature is incredibly powerful, versatile, and can replace most of the functionalities offered by Excel’s pivot tables. Read our article to find out how you can easily use the QUERY function to efficiently work with your Google Sheets data. Relational databases share many features with spreadsheets. When we explain what databases are, we often say that they are a bit like spreadsheets except they give us more control over larger amounts of data.

Why Should I Learn SQL Window Functions?

SQL has been around for more than 25 years. Its basic syntax – like SELECT, WHERE, GROUP BY, HAVING, and ORDER BY – is well known. But is there something besides traditional SQL? Can you go beyond the basics and improve your skills? The answer to this question is yes. There is a modern version of SQL. In this article, we are going to dive into the modern version and learn about SQL window functions.

What Is a Nested Query in SQL?

Have you ever wished that you could build a query with several SELECT statements? Good news! You can do this – and a lot more – with SQL’s nested queries. If you’ve been learning SQL (and maybe writing some queries) for a while, you’ve probably encountered cases where it looks like you need another SELECT statement inside your main statement. You may wonder “Is it possible to use nested SELECTs in SQL?

Advanced SQL Courses for Data Analysts – A Complete Review

Even data analysts who already know SQL need to keep their skills sharp. Where can you find the best advanced SQL courses for data analysts? Check out our review of the top online sources! In this article, I present a list of online SQL courses for data analysts. These courses are offered by various platforms. Why wait? Let’s jump right in! 8 Advanced SQL Courses for Data Analysts Let's take a closer look at these courses to decide which platform will be better for you in learning SQL.

You Want to Learn SQL? You've Come to the Right Place!

It is difficult to list all the benefits of learning SQL. You will work faster and more efficiently with a database, you will no longer be dependent on the IT department, and you will be able to analyze the data yourself and draw appropriate conclusions, among others. Add reporting to this, and you will get a very wide range of cool and useful skills. Maybe you want to change jobs or get a promotion?

How to Practice SQL for a Technical Job Interview

You’ve scored yourself an interview for an SQL-related job. Nice work! But perhaps uncertainty is creeping in as your interview date looms closer. Do you know enough SQL to make the cut? What questions are you likely to be asked? What SQL practice should you be doing before your interview? Almost all SQL job candidates go through exactly the same nerve-wracking process. Here at LearnSQL.com, we have the lowdown on all the SQL practice and preparation you’ll need to ace those interview questions and take your career to the next level.

Is SQL a Programming Language?

Updated on: October 30th, 2023 SQL is a powerful tool for communicating with database management systems. When you write SQL queries, you give instructions to the computer and it performs these instructions—it sounds like programming. However, you cannot build an application with SQL as you can with Python or Java. So, is SQL a programming language? For over 50 years, SQL, or Structured Query Language, has been a cornerstone in the world of data management.

SQL Course of the Month – Window Functions

Spring has come. It is nicer outside. It's a great time to learn something new. Which course should you choose? In April, it's worth it to bet on SQL window functions. What are they, what are they used for, and why are they worth knowing? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, these questions. She has a PhD in mathematics and over 10 years’ experience teaching mathematics and computer science at the University of Warsaw.

What Is a SQL Running Total and How Do You Compute It?

The SQL running total is a very common pattern, used frequently in finance and in trend analysis. In this article, you’ll learn what a running total is and how to write a SQL query to compute it. The best way to learn SQL is through practice. LearnSQL.com offers over 30 interactive SQL courses at various level of difficulty. Each course is interactive: there is a little bit of reading, followed by an exercise to practice what you've just read.

Is SQL Worth Learning?

We’re in the 21st century. These are the “ultimate data times” in which loads of information on all kinds of things is available. We want to explore this info even more, slice and dice it, understand where it comes from and what triggers it. With such large amounts of data coming in, people have discovered that spreadsheets aren’t enough. There’s a need for a greater solution, something like a spreadsheet on steroids.

Top 3 Platforms to Learn SQL Online: A Complete Comparison

Do you want to learn SQL online? Where do you start? There are many choices on the internet, and it can be hard to decide. But don’t worry—I tested and compared three major platforms to help you find the best place to learn SQL online! E-learning is on the rise. It gives us infinite possibilities of growing our professional careers without leaving our homes. And increasing our competencies is especially important now that the labor market has become dynamic and unstable.

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.

How to Join 3 Tables (or More) in SQL

Updated on: April 19, 2024 Using JOIN in SQL doesn’t mean you can only join two tables. You can join 3, 4, or even more! The possibilities are limitless. The best way to practice SQL JOINs is LearnSQL.com's interactive SQL JOINs course. It contains over 90 hands-on exercises that let you refresh your SQL JOINs knowledge. It covers a wide range of topics from simple 2-table JOINs, through joining multiple tables and using OUTER JOINs, to joining a table with itself.

Why Take the “SQL Basics” Course at LearnSQL.com

LearnSQL.com’s interactive “SQL Basics” course teaches the foundations of SQL. Discover why we built this online course, our philosophy behind it, and what it contains! What Is SQL, and Why Should You Learn It? SQL is a language used to talk to databases, computer programs that hold data and can process it efficiently. SQL can select data from a database and perform various computations on the data, be they simple or complex.

Differences Between GROUP BY and PARTITION BY

Window functions are a great addition to SQL, and they can make your life much easier if you know how to use them properly. Today, we will address the differences between a GROUP BY and a PARTITION BY. We’ll start with the very basics and slowly get you to a point where you can keep researching on your own. PARTITION BY vs. GROUP BY The PARTITION BY and the GROUP BY clauses are used frequently in SQL when you need to create a complex report.

What is the Best SQL Training Online?

Updated on: April 16, 2024 Mastering SQL training is crucial, but let's face it—you won’t become an expert in just a couple of weeks. With countless resources available, it can be quite a challenge to even know where to begin your SQL journey. How do you effectively practice and hone these essential skills? Savvy and knowledgeable database professionals have consistently been in high demand over the last five years. If you are aiming to advance your career as a database developer, administrator, warehousing specialist, or analyst, SQL training and mastery is an absolute necessity.

Analyze Time Series COVID-19 Data with Window Functions

The COVID-19 pandemic really changed the way we live. No matter where you are, you're being impacted by this unpredictable virus. We do not know what the future holds, but we do believe in science and in better days to come. One thing that makes me as a data analyst particularly happy is that we have publicly available data. We can analyze that data and learn something from it. If you want to explore COVID-19 with the help of modern SQL constructions, keep reading — this article is intended for you.

SQL Window Functions vs. GROUP BY: What’s the Difference?

A very common misconception among SQL users is that there is not much difference between SQL window functions and aggregate functions or the GROUP BY clause. However, the differences are very significant. Perhaps the only similar point between GROUP BY and window functions is that both allow you to execute a function (such as AVG, MAX, MIN, or COUNT) on a group of records. I’d say that window functions’ special power is that they allow us to obtain results that otherwise would be almost impossible to achieve.

Choose the Best Way to Learn SQL

SQL has become a hot topic in the professional world, and many resources have appeared both online and offline for learning SQL. It’s easy to get lost in the jungle of books, tutorials, and courses. Which resources do you choose? If you want to know how to learn SQL quickly and effectively, take a look at my list. There are many reasons for learning SQL. We asked our users about them and learned that there was no universal motive.

SQL Cookbook with Recipes for Success

The internet holds a lot of information and can provide solutions to various problems. SQL users, both beginners and advanced, often turn to the internet for help with SQL queries. This article will help you find the right SQL queries to solve your problems. Learn what the SQL Cookbook is and why you should use it. You will also find a list of the most important recipes, from which you will prepare a great SQL dish with the taste of success.

Are There Any Good SQL Courses for Marketers?

Looking for places to learn SQL online and level up your marketing efforts? Check out these SQL courses. Introduction With the help of IT experts, meticulous marketers analyze information to create advertising strategies. This commonplace state of affairs forces the marketer to rely on data experts and sometimes wait for their availability. But what if marketers could pull the data themselves? They can – by turning into a technical marketer.

How to Get the First Day of the Week in SQL Server

This is additional content for the LearnSQL.com course Customer Behavior Analysis in SQL Server. This interactive course will teach you how to analyze customer lifecycle in a SQL database in over 70 hands-on exercises. You will learn how to find out compare registration rates between periods of time, compute conversion rates in SQL, compare customer cohorts, analyze customer activity and customer churn over time. This course is essential for anyone doing customer analysis in their job.

How to Group Data by Week in SQL Server

This is additional content for the LearnSQL.com course Customer Behavior Analysis in SQL Server. In this course, we showed you how you can analyze the customer lifecycle (customer acquisition, conversion, activity, retention, and churn) with SQL. We discussed customer registration cohorts, or groups of customers who registered during the same period (e.g. same week, same month). Analyzing customer registration cohorts lets you see registration trends and relate registration cohorts with marketing campaigns.

Types of Database Jobs

Updated on: April 11, 2024 Do you dream of high earnings and interesting work? Are you fed up with your boss and his or her annoying vacation stories in exotic countries? Is it time to change your job? Why not learn SQL? Here are some examples of the types of database jobs that may lead you to a better life. What types of database jobs use SQL? Here are some examples, but first, a small caveat.

The 50 Best Resources for Learning SQL (Updated for 2024)

Updated on: December 6, 2023 Do you want to know where to learn SQL? We’ve got you covered with the ultimate list of 50 SQL learning resources, including the best SQL courses, tutorials, books, and much, much more! Learning SQL can be hard enough without wading through thousands of websites and articles. So, we thought we’d do you a solid and put the top SQL resources here in this handy slice of the internet.

Why Window Functions Are Not Allowed in WHERE Clauses

Window functions are extremely powerful, but there are a lot of nuances and little details you need to learn about using window functions in order to use them correctly and efficiently. A fairly common question SQL users have is why window functions are not allowed in WHERE. TL;DR: You can use window functions in SELECT and ORDER BY. You cannot use window functions in WHERE, GROUP BY, or HAVING.

How to Practice SQL After a Video Course

Updated on: April 19, 2024 When you're just starting to learn coding, the most obvious first step is to watch online video courses. They're one of the most popular ways to learn the basics of a new technology without investing a lot of time and money. But you need to do more than that to master the topic. What should be your next step? When someone asks me about how to start learning to code, I often recommend trying video tutorials first.

How to Rank Rows in SQL: A Complete Guide

Don’t struggle with SQL ranking functions anymore! This article will guide you through the most common ranking use cases. Rankings are used around us every day. Sports tournaments, the best movies and TV series on Netflix, stores with the cheapest products—these are only a few examples of rankings you might’ve seen recently. Using SQL RANK functions might be hard sometimes. The variety of different constructions is enormous. You can easily get lost in everything there is to learn about ranking.

How to Practice SQL JOINs

Updated on: November 7, 2023 There is no better way to learn how to practice SQL joins than through hands-on experience. However, there will probably be obstacles along the way. I’ll cover some of these obstacles and give ideas for how to overcome them. While this article won’t turn you into SQL JOINs expert, it will show you how to become one. So, let’s start! Diving into the world of databases?

Stay at Home and Learn SQL for Free with LearnSQL.com

Working remotely is a dream come true for some. You ditch commuting and have more time for the people you love and the things you enjoy. For others, it's a challenge to maintain their focus when there are new distractions. It's also an opportunity to invest the few gained hours in learning something new. Staying at home can be a time when you might find yourself busier than you've ever been, but not getting many things done, and worse, not learning what you planned to.

Video Tutorial or Interactive SQL Course – Which Is Better?

Are you ready to get started with SQL but unsure which learning method is the most effective? In this post, we’ll talk about the pros and cons of learning SQL from an instructional video vs. an interactive online course. Are you a chronic Internet-using student who’s planning to learn SQL? Maybe you did some research but still don’t know which kind of training is worth your (limited) time. We all have families, hobbies, and other after-work commitments, and finding the right resource for learning SQL will save you some time.

How Will Learning SQL Improve My Daily Work?

Whether you want to boost your professional development, learn in-demand skills, or start something new and interesting, learning SQL will make your life easier in many ways. Are you thinking of learning SQL but aren’t sure if it's a good idea? At first glance, learning SQL may seem completely useless, especially if the industry you are in is not related to IT. But that's not true. Although your position in the company may not imply that you code every day, you can still gain a lot from SQL.

How to Start Writing SQL Reports

Updated on: April 23, 2024 So, you’ve started, or want to start, learning SQL. You understand that a database is a repository for raw data and that data in business forms the backbone of the decision-making process. But how do you gain meaningful insights from raw data? How can you take a vast amount of information from a database and use SQL to give it a real-world utilization? Learn how to write SQL reports!

Learning SQL? 12 Ways to Practice SQL Online

If you’re currently learning SQL, you may have found yourself knee-deep in reading material and may be wondering how on earth you can bridge the gap between book knowledge and real-life SQL application. In this article, we bring you 12 of the most effective ways to practice SQL online, taking you from a bookworm to a database butterfly in no time at all! All theory and no practice will make you a frustrated SQL user!

How to LEFT JOIN Multiple Tables in SQL

Can you LEFT JOIN three tables in SQL? Yes, indeed! You can use multiple LEFT JOINs in one query if needed for your analysis. In this article, I will go through some examples to demonstrate how to LEFT JOIN multiple tables in SQL and how to avoid some common pitfalls when doing so. The best way to practice different types of joins is our interactive SQL JOINs course. It contains over 90 hands-on exercises that cover simple 2-table joins, joining multiple tables, LEFT JOIN, FULL JOIN, and many more.

Best Online SQL Courses for Finance & Economics Majors

Are you studying finance and wondering how you can use your knowledge in this technical world? Maybe you’ve just started working as a data analyst and you want to bring new tools and skills to your workplace? This article could help you with the list of the SQL courses worth trying. Maybe you’re studying finance and find your studies too theoretical. How will you put this knowledge into practice?

Should I Learn SQL as a Data Analyst?

So, you are a data analyst—someone who relies on data. You like to gather, clean, and transform data and come to conclusions based on data. You are a data detective. Which tool do you choose to do your job in an elegant, reproducible, and simple way? Excel? R? Python? Or should you learn SQL? Stay tuned! In this article, I will explain why SQL is a must-have skill for data analysts.

Top 10 Websites That Will Help You Find the Perfect SQL Job

Updated on: March 6, 2024 People learn SQL for many reasons. In my case, I wanted to find a better job that would allow me to earn more and have more free time. But where do you find such a job? Here is my list of the 10 best websites with database jobs. Although SQL is over 40 years old, it is appearing in more and more job advertisements. Data has become an essential tool for businesses, and they are looking for people to squeeze every bit of information from their databases.

Common Entry Level SQL Developer Interview Questions

Have you ever been interviewed for an entry-level SQL position? Are you planning to apply for such a job? This article will help you to know what to expect and prepare for common SQL developer interview questions. After gaining some basic knowledge of SQL and programming, you're probably wondering what to do next. Or maybe you're not wondering! You know that what you've learned will soon disappear if you don't use it regularly.

How to Become an SQL Developer

There is no simple answer to the question “How do you become an SQL developer?” However, if the answer were too complex, there would be no point in writing this article, and yet I’m doing it. So, somewhere along the way, we’ll find the answer. As said in the intro, there is no magic wand that will turn you into an SQL developer. But reading this article will save you some time and help you focus on what is important to achieve your goal.

How to Concatenate Strings in SQL

Problem: You want to join strings from two columns of a table into one. Example: Our database has a table named student with data in the following columns: id, first_name and last_name. idfirst_namelast_name 1LoraSmith 2EmilBrown 3AlexJackson 4MartinDavis Let’s append the first name to the last name of the student in one string. Use a space between each name.

How to Filter Records with Aggregate Function AVG

Problem: You want to filter groups of rows in by the average value of a given column. Example: Our database has a table named product with data in the following columns: id, name, store and price. idnamestoreprice 1milkGreen Shop2.34 2breadClark’s Grocery3.56 3breadSuper Market4.15 4milkSuper Market1.80 5breadGrocery Amanda2.26 6milkViolet Grocery3.45 7milkClark’s Grocery2.10 8breadViolet Grocery2.

How to Filter Records with Aggregate Function COUNT

Problem: You want to find groups of rows with a specific number of entries in a group. Example: Our database has a table named product with data in the following columns: id, name and category. idnamecategory 1sofafurniture 2glovesclothing 3T-Shirtclothing 4chairfurniture 5deskfurniture 6watchelectronics 7armchairfurniture 8skirtclothing 9radio receiverelectronics Let’s find the category of products with more than two entries.

How to Filter Records with Aggregate Function SUM

Problem: You need to filter groups of rows by the sum of a given column. Example: Our database has a table named company with data in the following columns: id, department, first_name, last_name, and salary. iddepartmentfirst_namelast_namesalary 1marketingLoraBrown2300 2financeJohnJackson3200 3marketingMichaelThomson1270 4productionTonyMiller6500 5productionSallyGreen2500 6financeOlivierBlack3450 7productionJenifferMichelin2800 8marketingJeremyLorson3600 9marketingLouisSmith4200 Let’s find the names of departments that have sums of salaries of its employees less than 7000.

How to Filter Rows without NULL in a column

Problem: You want to find records without a NULL in a column. Example: Our database has a table named product with data in three columns: id, name, and price. idnameprice 1butterNULL 2milk2.35 3bread3.25 4cheeseNULL Let’s find the names and prices of products that have a price (without a NULL). Do this by using the IS NOT NULL operator.

How to Find Records with NULL in a Column

Problem: You want to find records with NULL in a column. Example: Our database has a table named children with data in four columns: id, first_name, middle_name, and last_name. idfirst_namemiddle_namelast_name 1JohnCarlJackson 2TomNULLThomson 3LisaAliceNULL 4AnneNULLSmith Let’s find the id, first name, and last name of children without a middle name (NULL in column middle_name). We use the IS NULL operator for this. Solution: SELECT id, first_name, last_name FROM children WHERE middle_name IS NULL; Here’s the result:

How to Find Rows with Maximum Value

Problem: You want to find rows which store the largest numeric value in a given column. Example: Our database has a table named student with data in the following columns: id, first_name, last_name, and grade. You want to find the students who have the highest grades. idfirst_namelast_namegrade 1LisaJackson3 2GaryLarry5 3TomMichelin2 4MartinBarker2 5EllieBlack5 6MarySimpson4 Solution: SELECT id, first_name, last_name, grade FROM student WHERE grade = (SELECT MAX(grade) FROM student); Here’s the result:

How to Find Rows with Minimum Value

Problem: You want to find rows which store the smallest numeric value in a column. Example: Our database has a table named weather with data in the following columns: id, city, and temperature. You want to find cities with the lowest temperature. idcitytemperature 1Houston23 2Atlanta20 3Boston15 4Cleveland15 5Dallas34 6Austin28 Solution: SELECT id, city, temperature FROM weather WHERE temperature = (SELECT MIN(temperature) FROM weather); Here’s the result:

How Long Does It Take to Learn SQL?

Is it hard to learn SQL? How long does SQL mastery take? This article will answer those questions and get you started with the most useful SQL commands. How long does it take to learn SQL? If you’ve ever dabbled in Spanish or French, you know that learning a new language is tough and can take years. Luckily, mastering SQL is a much faster journey than conquering por/para or un, deux, trois.

How to Convert a String to Uppercase in SQL

Problem: You would like to convert a string to uppercase in SQL. Example: Our database has a table named questionnaire with data in the following columns: id, first_name, last_name, and favorite_car. idfirst_namelast_namefavorite_car 1AlanJacksonHonda Civic 2ElisaThomsonTOYOTA Camry 3MaryMartinesNissan rogue 4ChrisBrownford focus 5AdamSpringRam PICKUP Our table stores the make and model of the favorite car for each person who filled out our questionnaire.

How to Find the Average of a Numeric Column in SQL

Problem: You’d like to calculate the average of numbers stored in a column. Example: Our database has a table named sale with data in the following columns: id, city, year, and amount. idcityyearamount 1Los Angeles20172345.50 2Chicago20181345.46 3Annandale2016900.56 4Annandale201723230.22 5Los Angeles201812456.20 6Chicago201789000.40 7Annandale201821005.77 8Chicago20162300.89 Let’s calculate the average sales, regardless of city or year.

How to Find the Maximum Value of a Numeric Column in SQL

Problem: You’d like to find the maximum value of a numeric column. Example: Our database has a table named product with data in the following columns: id, name, year, and items. idnameyearitems 1bread roll2018345 2chocolate2017123 3butter201934 4bread roll2019456 5butter201856 6butter201778 7chocolate201987 8chocolate201876 Let’s find the maximum number of items sold over all years.

How to Find the Minimum Value of a Column in SQL

Problem: You’d like to find the smallest numeric value in a column. Example: Our database has a table named employment with data in the following columns: id, first_name, last_name, department, and salary. idfirst_namelast_namedepartmentsalary 1EllieMartinesmarketing1200 2MartinJohnsonfinance2300 3MichaelJacobsproduction1100 4StephenKowalskimarketing4300 5StanleyMillermarketing3500 6JenyBrownfinance5000 7MargaretGreenmarketing1500 8LisaThomasproduction2800 Let’s find the lowest salary among all employees.

How to Number Rows in SQL

Problem: You would like to give each row in the result table a separate number. Example: Our database has a table named furniture with data in the following columns: code (primary key) and name. codename 101bed 202sofa 333chair 123bookcase 235table 766desk The furniture table stores the name of pieces of furniture that we want to number.

What’s the Difference Between RANK and DENSE_RANK in SQL?

Problem: You want to compare the rankings produced by RANK and DENSE_RANK and add them as new columns to a table. Example: Our database has a table named sales_assistant with data in the following columns: id (primary key), first_name, last_name, month, and sold products. idfirst_namelast_namemonthsold products 1LisaBlack 52300 2MaryJacobs52400 3LisaBlack 62700 4MaryJacobs62700 5AlexSmith 62900 6MaryJacobs71200 7LisaBlack 71200 8AlexSmith 71000 Let’s display each sales assistant’s first and last name and number of sold products.

HAVING vs. WHERE in SQL: What You Should Know

This article is about SQL’s WHERE and HAVING clauses. Both clauses are part of the foundations of the SQL SELECT command. They have similar uses, but there are also important differences that every person who uses SQL should know. Let’s see what’s behind the HAVING vs. WHERE debate. In this article, we’ll suppose we work for a government social agency supporting people or families whose income is below a certain threshold.

How to Practice SQL

Updated on: December 5th, 2023 Are you familiar with SQL's core concepts like aggregation functions, JOINs, GROUP BY, and ORDER BY? That's a great start. But to truly master SQL – especially for data analyst roles and job interviews – it's crucial to understand how to practice SQL effectively. This article provides a comprehensive guide to the best methods to practice SQL. You’re here because you're eager to enhance your SQL skills and become an independent database user.

SQL INSERT, SQL UPDATE, SQL DELETE – Oh My!

Need to understand SQL INSERT, UPDATE, or DELETE? We'll get you up to speed with a comprehensive How-To and useful examples! SQL INSERT, UPDATE, and DELETE statements—what are they all about? If you're a data engineer, a database administrator, or even just your average data fanboy or girl, one day you're going to find yourself with a database that becomes your "baby." Charged with this special bundle of joy, you're going to need to feed and change the little fella.

SQL, Databases, and Hollywood Movies

Policemen, doctors, lawyers, scientists, teachers: These are the professions that we often see in Hollywood movies. But are movies also trying to show what the work of data analysts looks like? Here is a list of six movies in which screenwriters, directors, and producers decided to cast SQL and databases in the main roles. Data analysis is most often associated with business, reporting, and making key decisions for the company.

Difference between GROUP BY and ORDER BY in Simple Words

For someone who is learning SQL, one of the most common places to get stuck is when learning the GROUP BY command. GROUP BY and ORDER BY are two important keywords in SQL that we use to organize data. The difference between GROUP BY and ORDER BY is that ORDER BY is more simple than GROUP BY and is usually introduced early in an SQL course. Sometimes, people are quite confused over these two concepts (SQL ORDER BY vs.

How to Add Rankings with DENSE_RANK() in SQL

Problem: You want to add a ranking position to rows consecutively, even if the rows have the same values. Example: Our database has a table named competition with data in the following columns: id (primary key), first_name, last_name, and score. idfirst_namelast_namescore 11JohnThomas345 14MaryJohnson222 16LisaBrown154 23AlanBlake222 32ChrisTaylor154 Let’s display all details about students: their last name, first name, and scores sorted by score in descending order.

How to Floor Numbers in SQL

Problem: You want to round a number down to the nearest integer. Example: Our database has a table named employee with data in the following columns: id, first_name, last_name, and hours_worked (for the current month). idfirst_namelast_namehours_worked 1AlanWatson95 2LisaBlack225 3LauraWilliams104 Let’s show the first and last name of each employee along with the number of days they worked.

How to Round Numbers in SQL

Problem: You want to round a number to a specific number of decimal places in SQL. Example: Our database has a table named product with data in the following columns: id, name, and price_net. idnameprice_net 1bread2.34 2croissant1.22 3roll0.38 Suppose there’s a tax of 24% on each product, and you’d like to compute the gross price of each item (i.e., after taxes) and round the value to two decimal places.

How to Round Up a Number to the Nearest Integer in SQL

Problem: You want to round up a number to the nearest integer in SQL. Example: Our database has a table named rent with data in the following columns: id, city, area, and bikes_for_rent. idcityareabikes_for_rent 1Los Angeles1302.151000 2Phoenix1340.69500 3Fargo126.44101 Let’s show each city’s name along with the ratio of its area to the number of bikes for rent.

How to Use LIKE in SQL

Problem: You need to search for specific patterns (certain combinations of letters or numbers) within text data in your database. We'll show you how to use the LIKE operator in SQL to: Find city names starting with S Find city names with exactly five characters Find city names starting with S and with o as the second-to-last character You'll also learn how to use LIKE and wildcard operators in SQL to find your own patterns in text data in your database.

How to Count the Number of Rows in a Table in SQL

Problem: You’d like to determine how many rows a table has. Example: Our database has a table named pet with data in the following columns: id, eID (electronic identifier), and name. ideIDname 123456sparky 223457mily 3NULLlessy 4NULLcarl 534545maggy Let’s count all rows in the table. Solution: COUNT(*) counts the total number of rows in the table:

How to Replace Part of a String in SQL

Problem: You’d like to replace part of a string with another string. Example: Our database has a table named investor with data in the following columns: id, company, and phone. idcompanyphone 1Big Market123–300-400 3The Sunny Restaurant123–222-456 4My Bank123-345-400 We’d like to change the phone number format for each company by replacing the hyphen character with a space.

How to Sum Values of a Column in SQL?

Problem: You’d like to sum the values of a column. Example: Our database has a table named game with data in the following columns: id, player, and score. idplayerscore 1John134 2Tom 146 3Lucy20 4Tom 118 5Tom 102 6Lucy90 7Lucy34 8John122 Let’s find the total score obtained by all players. Solution: SELECT SUM(score) as sum_score FROM game; Here’s the result:

How to Trim Strings in SQL

Problem: You’d like to remove specific characters from the beginning and end of a string in SQL. Example: Our database has a table named post with data in two columns: id and title. idtitle 1' News about dogs ' 3'Eurovision 2019 ' 4'New political climate' Let’s trim the title of each post to remove the unnecessary space at the beginning and end.

How to Count Distinct Values in SQL

Problem: You’d like to count how many different non-NULL values there are in a given column. Example: Our database has a table named customer with data in the following columns: id, first_name, last_name, and city. idfirst_namelast_namecity 1JohnWilliamsChicago 2TomBrownAustin 3LucyMillerChicago 4EllieSmithDallas 5BrianJonesAustin 6AllanDavisNULL Let’s find the number of different (and non-NULL) cities.

How to Eliminate Duplicate Rows in SQL

Problem: You’d like to eliminate any duplicate rows from the result set of a query so that each row appears only once. Example: Our database has a table named clothes with data in the following columns: id, name, color, and year_produced. idnamecoloryear_produced 1T-shirtyellow2015 2jacketblue2016 3jeansblack2015 4jacketblue2015 5jacketgreen2016 6jacketyellow2017 7hatyellow2017 Let’s get the non-repeated names and colors of clothes produced before 2017.

How to Find Duplicate Rows in SQL?

Problem: You have duplicate rows in your table, with only the IDs being unique. How do you find those duplicate entries? Example: Our database has a table named product with data in the following columns: id, name, and category. idnamecategory 1steakmeat 2cakesweets 3steakmeat 4porkmeat 5cakesweets 6cakesweets Let’s find duplicate names and categories of products.

How to Handle Divide by Zero In SQL

Problem: You want to perform division in your SQL query, but the denominator is an expression that can be zero. The database will give you an error when the denominator is in fact zero. Example: Our database has a table named investor_data with data in the following columns: id, investor_year, price_per_share, income, and expenses. idinvestor_yearprice_per_shareincomeexpenses 120162032002300 2201713020002000 3201840200100 420191559004900 Let’s divide the price per share by the difference between income and expenses to determine the P/E ratio (price-earnings ratio) for each year.

How to Join on Multiple Columns

Problem: You want to join tables on multiple columns by using a primary compound key in one table and a foreign compound key in another. Example: Our database has three tables named student, enrollment, and payment. The student table has data in the following columns: id (primary key), first_name, and last_name. idfirst_namelast_name 1EllieWillson 2TomBrown 3SandraMiller The enrollment table has data in the following columns: primary key (student_id and course_code), is_active, and start_date.

How to Multiply Two Columns in SQL

Problem: You want to multiply values from two columns of a table. Example: Our database has a table named purchase with data in the following columns: id, name, price, quantity, and discount_id. idnamepricequantitydiscount_id 1pen731 2notebook582 3rubber1131 4pencil case2423 Let’s multiply the price by the quantity of the products to find out how much you paid for each item in your order.

How to Order By Two Columns in SQL?

Problem: You need to display records from a given table sorted by two columns. Example: Our database has a table named employee with the following columns: id, first_name, last_name, and salary. idfirst_namelast_namesalary 1LisaUlman3000 2AdaMuller2400 3ThomasGreen2400 4MichaelMuller3000 5MaryGreen2400 Let’s display all information for each employee but sort the records according to salary in descending order first and then by last name in ascending order.

How to Order by Count in SQL?

Problem: You aggregated data into groups, but you want to sort the records in descending order by the number of elements in the groups. Example: Our database has a table named user with data in the following columns: id, first_name, last_name, and country. idfirst_namelast_namecountry 1LisaWilliamsEngland 2GaryAndersPoland 3TomWilliamsPoland 4MichaelBrownFrance 5SusanSmithUSA 6AnneJonesUSA 7EllieMillerPoland Let’s create a report on our users.

How to Order Alphabetically in SQL

Problem: You want to display records from a table in alphabetical or reverse-alphabetical order according to given column. Example: Our database has a table named customer. The customer table contains data in the id, first_name, and last_name columns. id first_name last_name 1 Susan Thomas 2 John Michael 3 Tom Muller Let’s display each customer’s information, sorted in ascending order by their last name.

Join us on Facebook–We Can Learn More Together

We are so happy that you have joined us to learn and develop your SQL skills! We want to invite you to a new Facebook group, We Learn SQL. It is a great place for anyone interested in meeting like-minded people who also want to learn about database-related concepts. Learning together is easier, don't you think? Joining this group is a great opportunity to begin sharing your learning experiences with others.

Grouping Data in SQL Server

People who work with data know that data grouping can sometimes be a chore. If you struggle and waste hours with Excel, OpenOffice, or some other tool trying to group various sets of data, take a look at this article and learn how to do the work much quicker and easier by using SQL. You often find yourself in a situation where you need to analyze data and present the results in a form other than the one in which the data is stored.

SQL Order of Operations

SQL is not a traditional programming language in which you write a sequence of instructions in a given order of execution. Instead, SQL is a "declarative" language, which means that by writing a SQL query, you declare what data you expect as a result of the query, but you don't indicate how to obtain it. Six Operations to Order: SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY By using examples, we will explain the execution order of the six most common operations or pieces in an SQL query.

Why Use SQL Over Excel

SQL is replacing Excel in many fields, and data analysis is certainly one of them. If you are still using Excel as a data analyst, you are missing something very valuable. SQL can make your life easier, as it's more efficient and faster than Excel. So, how and from where can you learn SQL? How Can SQL Help Data Analyst? You can use SQL to help you with the following work:

The Most Important SQL Queries for Beginners

How do you get data from a table? How do you create or delete a table? How do you display distinct records? How do you select rows which store a specific value in a column? You can easily do all of this by writing basic SQL queries. This guide discusses the 30 most important SQL queries for beginners. Let's take a look. 1. Retrieving Data From All Columns This is a very basic query to display all data from a table.

YouTube Tutorials That Actually Teach You Some SQL

YouTube is not just funny cats, music clips, and viral videos. It can also be a mine of knowledge – if you know where to look. Can YouTube tutorials really help you learn SQL? Let's say you're a marketer or an accountant. You work with databases every day. But when it’s time to write a query and get specific data, you need to call someone from IT. Why not learn to do it yourself?

24 Rules to the SQL Formatting Standard

Writing queries to a database requires knowledge about SQL syntax, but this is not all you should know. Best practices for writing professional SQL code require good formatting skills. In this article I discuss why this is so important and what are the basic rules you should follow. Why is it Worthwhile to Format SQL Code? Beginner SQL programmers often don't pay much attention to formatting their code. If you think formatting is something that can be safely ignored, look at the code below:

SQL INNER JOIN Explained in Simple Words

In this article, I will cover perhaps the most important element of the SQL language. That's right! I'm talking about the SQL INNER JOIN clause. As you know, in a database the data are stored in several tables. In my last article, I covered how to create SQL queries when the data you need is in only one table. But what if the data you need is in two tables?

Forget About Excel, High Five With SQL

Find out why you should forget about Excel and start using SQL even if you're not an IT expert. We'll show you how easy it is to learn SQL, how it can make you work better, and how LearnSQL.com makes the learning process fun. "I Don't Deal With Data" We frequently hear the sentence above from people outside the IT industry. Well, it's not entirely true. Data is now almost everywhere.

Get to Know the Power of SQL Recursive Queries

Most commonly, the SQL queries we run on a database are quite simple. Well, that depends on your role, of course. Analysts in data warehouses retrieve completely different sorts of information using (very often) much more complicated queries than software engineers creating CRUD applications. However, sometimes it's simpler or more elegant to run a query that is a little bit more sophisticated without needing further data processing in the code.

SQL Filtering 101

Sometimes, SQL queries return lots of data you don't need. In this article, we'll look at a simple example of filtering SQL queries to reduce the complexity of your data. The key to learning how to filter data in SQL is understanding the very basics of Boolean algebra. That's just a fancy term mathematicians use to describe expressions involving logical values (true/false) and their associated operators (and, or, not, etc.

Improving Query Readability with Common Table Expressions

What is a Common Table Expression, or CTE? Where do you use them, and why? This post answers your questions. Simply put, Common Table Expressions (also known as WITH clauses) are essentially named subqueries. They also provide additional features like recursion. If you're new to subqueries, I recommend you read the SQL Subqueries article before continuing. The main purpose of Common Table Expressions is to improve the design and readability of an SQL statement.

Grouping, Rolling, and Cubing Data

The first two articles in this series highlighted SQL Server's ability to organize data into user-defined windows and its aggregate functions. Part 3 will focus on other methods of aggregating and organizing data using built-in SQL Server features – specifically, its grouping functions. For consistency, the same base data will be used as in the first two parts of this series. CREATE TABLE WindowTable (WindowID INT IDENTITY, House Varchar(32), FullName Varchar(64), PhysicalSkill Decimal(4, 2), MentalSkill Decimal (4, 2)) GO

Performing Calculations on Date- and Time-Related Values

Relational databases support several date and time data types. In this article, we'll look at several arithmetic operations we can do on these types. These operations are logical and understandable, even for the beginning SQL coder. Let's first briefly explain the main data types used for dates and times. Keep in mind that data types may differ by database engine, so check your database documentation for specifics before you start working with them.

Do it in SQL: Recursive SQL Tree Traversal

In the previous article, I described how to use Common Table Expressions to find the shortest path in a directed graph. That example could be hard to follow, I admit. Let’s do something much more common, something that is implemented on almost every website – a menu. Instead of writing the code, we’ll take advantage of the SQL tree structure writing just one query. We’ll use CTEs for PostgreSQL and the hierarchical query clause for Oracle.

Window Functions: Part Two: Aggregating Data

In part one of this series on SQL Server window functions, the functionality of the OVER() clause was discussed. This article will focus on aggregate functions. The majority of these can be used in conjunction with OVER. Some, like SUM() and AVG(), are widely used. Others — including VARP() and CHECKSUM_AGG() — are not as well-known, but are potentially quite useful. OVER defines the user-specified range on which a function is applied.

Window Functions in SQL Server: Part One: The OVER() Clause

Window functions were first introduced in standard SQL 2003 and then extended in SQL 2008. Since SQL Server 2005, Microsoft has been steadily improving window functions in the database engine. These functions perform an aggregate operation against a user-defined range of rows (the window) and return a detail-level value for each row. Well-known aggregate functions include SUM, AVG, MIN, MAX, and many others. Recent versions of SQL Server have introduced ranking and analytic functions such as LAG, LEAD, RANK, CUME_DIST, and many others.

Pivot Tables in PostgreSQL Using the Crosstab Function

Some years ago, when PostgreSQL version 8.3 was released, a new extension called tablefunc was introduced. This extension provides a really interesting set of functions. One of them is the crosstab function, which is used for pivot table creation. That's what we'll cover in this article. The simplest way to explain how this function works is using an example with a pivot table. First, we will explain our initial point from a practical perspective, then we'll define the pivot table we want.

5 Tips to Optimize Your SQL Queries

The SQL Language seems easy to learn – the commands follow a simple syntax and don't describe the specific algorithms used to retrieve data. The simplicity might, however, be deceptive. Not all the database functions operate with the same efficiency. Two very similar queries can vary significantly in terms of the computation time. This article presents some of the best practices that can greatly boost your SQL queries. 1. Learn How to Create Indexes Properly Learning how to index properly is the best thing you can do to improve the performance of your SQL queries.

How Does a Database Sort Strings?

Different languages have different alphabets and different ways to order letters within those alphabets. For example, a Polish character Ł comes right after L and before M. In Swedish, a letter Å comes almost at the end, right after Z. In French diacritics marks have no impact on the alphabetical order, so the letters À, Á and  are treated as the letter A when sorting strings. A collation is a set of rules that defines how to compare and sort character strings.

Basic Date and Time Functions in MS SQL Server

As a follow up to our article “The Most Useful Date and Time Functions in Oracle Database”, let’s review what date and time functions look like in MS SQL Server. Let’s start with functions that extract a year, month and day from a given date. declare @dt date = '2014-10-20' select year (@dt) as year, month (@dt) as month, day (@dt) as day SQL Server uses GETDATE() and SYSDATETIME() to get a current date and time.

The Most Useful Date and Time Functions

Date and time functions and formats are quite different in various databases. In this article, let's review the most common functions that manipulates dates in an Oracle database. The function SYSDATE() returns a 7 byte binary data element whose bytes represents: century, year, month, day, hour, minute, second It's important to know that select sysdate from dual in SQL*Plus gives the same result as select to_char(sysdate) from dual because SQL*Plus binds everything into character strings so it can print it.

S.Q.L or Sequel: How to Pronounce SQL?

SQL has been around for decades and supports a many billion dollar market. However, many people still struggle with just how to pronounce the term SQL. Is it "S.Q.L" [ˈɛs kjuː ˈɛl] or is it "sequel" [ˈsiːkwəl]? If you want to learn or review the basic SQL knowledge, check out our interactive SQL Basics course. It has over 100 hands-on exercises and covers the offers a complete SQL tutorial. (Here are more reasons why should take it.

SQL vs. Mongo query

In recent times, NoSQL databases have become a hot topic and have gained a crowd of advocates. Indeed, when NoSQL database started to arise, SQL-to-NoSQL converters arose with them as well. But unfortunately, thanks to the code conversion possibility, SQL supporters gained unquestionable evidence that in many cases the good, old SQL is much easier to use. Especially when it comes to queries. I performed a quick Google search and found plenty of nice converter tools.

DELETE RETURNING clause in PostgreSQL

The standard DELETE statement in SQL returns the number of deleted rows. DELETE FROM external_data; DELETE 10 In PostgreSQL you can make DELETE statement return something else. You can return all rows that have been deleted. DELETE FROM external_data RETURNING *; id | creation_date | user_id | data ----+---------------------------+---------+---------------- 101 | 2014-05-06 13:10:45.09484 | 23 | 'Some text' 102 | 2014-06-10 22:23:12.12045 | 25 | 'Some other text' (2 rows) DELETE 2

How to Select the First Row in a Group?

Often you want to select a single row from each GROUP BY group. PostgreSQL has a statement especially for that: SELECT DISTINCT ON. Let's say I want to select one weather report for each location. location time report Ottawa 2014-05-15 8:00 sunny 2014-05-15 11:00 cloudy 2014-05-15 15:00 rainy Warsaw 2014-05-15 8:00 overcast 2014-05-15 11:00 sunny 2014-05-15 15:00 rainy SELECT DISTINCT ON (location) location, time, report FROM weather_reports;

MySQL's group_concat Equivalents in PostgreSQL, Oracle, DB2, HSQLDB, and SQLite

The GROUP_CONCAT() function in MySQL MySQL has a very handy function which concatenates strings from a group into one string. For example, let's take a look at the children table with data about parents' and children's names. if (typeof VertabeloEmbededObject === 'undefined') {var VertabeloEmbededObject = "loading";var s=document.createElement("script");s.setAttribute("type","text/javascript");s.setAttribute("src", "https://my.vertabelo.com/js/public-model/v1/api.js");(document.getElementsByTagName("head")[0] || document.documentElement ).appendChild(s);} parent_name child_name John Tom Michael Sylvie John Anna Michael Sophie To get the names of children of each person as a comma-separated string, you use the GROUP_CONCAT() function as follows:

Tag: Sql Analytic Functions

Common SQL Window Functions: Positional Functions

Positional SQL window functions deal with data's location in the set. In this post, we explain LEAD, LAG, and other positional functions. SQL window functions allow us to aggregate data while still using individual row values. We've already dealt with ranking functions and the use of partitions. In this post, we'll examine positional window functions, which are extremely helpful in reporting and summarizing data. Specifically, we'll look at LAG, LEAD, FIRST_VALUE and LAST_VALUE.

SQL Window Functions: Partitions and Ranking Functions

You’ve started your mastery of SQL window functions by learning RANK, NTILE, and other basic functions. In this article, we will explain how to use SQL partitions with ranking functions. Mastering SQL window functions (AKA analytical functions) is a bumpy road, but it helps to break the journey into logical stages that build on each other. In the previous Common SQL Functions article, you learned about the various rank functions, which are the most basic form of window functions.

How to Use Rank Functions in SQL

Want to learn how to use ranking functions in SQL? They are a good choice if you want to start using SQL window functions! Learning about SQL window functions usually comes after you’ve built a foundation in the language, but these powerful functions take your skills up a level. As you master them, you’ll find better ways to solve query problems. When used for business intelligence applications, SQL queries combine data retrieval and advanced computations.

Statistics in SQL: Measuring Spread of Distribution

Besides knowing the centers of a distribution in your data, you need to know how varied the observations are. In this article, we’ll explain how to find the spread of a distribution in SQL. Are you dealing with a very uniform or a very spread population? To really understand what the numbers are saying, you must know the answer to this question. In the second part of this series, we discussed how to calculate centers of distribution.

Tag: Sql Basics

Top 5 SQL Tutorials for Beginners

Is learning SQL with tutorials a good idea? What tutorials are tailored to your needs? Our top 5 SQL tutorials for beginners will help you find your way! The idea to learn SQL is one of the best you could have. But to succeed, you need a good source of knowledge. In this article, we focus on online tutorials. We will describe different platforms, methods used, key features, prices. After reading this, you’ll be able to choose the best beginner-level SQL tutorial for you.

The Best Online SQL Editors

When it comes to online SQL editors, you have lots of options. Find out what features you should look for and what editors we prefer in this article. In this article, I'm going to share my insights on online SQL editors. These handy web-based tools have made my SQL query execution and database management tasks much simpler and more accessible – especially when compared to traditional desktop software. I'll discuss their key features and offer guidance on choosing the right one for different needs, whether you're a beginner or an experienced user.

Basic SQL Query Practice Online: 20 Exercises for Beginners

These 20 exercises are just what beginners need for SQL query practice. Try to solve each of them, and then look at the solutions. If something needs to be clarified, there are explanations for each solution. In this article, there’ll be less talking than usual. Instead, you’re going to write the answers to SQL practice queries. (Don’t worry; we’ve included the solutions if you get stuck.) The whole point is to give you, as a beginner, plenty of opportunities for SQL query practice.

An SQL Basics Primer for Non-IT Professionals

You don’t need to be an IT professional to understand SQL. Our quick primer of SQL basics is perfect for beginners without any computer science or programming background. If you’ve ever tried to learn a new software program, you know it takes more than just a few minutes. But it doesn’t mean you can’t learn it! The same is true if you want to learn SQL and databases. Even if you don’t have an IT background, you can do it.

How to Learn SQL Without Any Programming Knowledge

If you think that learning SQL is only for programmers, you are deeply wrong. This skill is totally within your grasp! SQL is not just popular and in demand; it’s also quite easy and intuitive to learn. Read on to find out more! You’re searching for inspiration on how to start learning SQL. Maybe you want to change your job, or want to become more competitive in the job market.

The Most Important SQL Commands

In this article, we'll explore the most common SQL commands that everyone should know, including SELECT, INSERT, WHERE and more. We’ll also give examples of how to use each command. Are you ready to dive into the world of databases? SQL, or Structured Query Language, is a programming language that is designed specifically to interact with databases. It allows you to manipulate the data in databases in multiple ways – e.

How to Learn SQL

It takes quite an effort to learn SQL or any new skill for that matter. But pushing hard is not enough to learn it successfully. You can sit for hours and still feel like you're not making progress. So, what do you do? Let it go or try even harder? I say: work smart, not hard. SQL (Structured Query Language) is one of the most popular programming languages. It is an invaluable tool in a world overflowing with data.

5 Tips for Learning SQL for Beginners

Being data-driven is a hot trend right now. Employers are looking for people who can work with databases. This is why you should learn SQL. In this article, I'll explain how to go about doing so. Yes, learning SQL may be the right thing for you even if you have never seen a line of code. As with any new skill, it requires the right approach and the right resources.

Will SQL Ever Be Replaced?

Is it worth learning SQL? Is it possible that one of the modern programming languages or no-code solutions will replace SQL very soon? No; it is not that easy to replace SQL and relational databases. Let’s see why SQL is future proof – and why learning it will pay off for many years to come. If you are building your career in a data-driven company, you are probably looking into opportunities to enhance your skill set in data management and data analysis.

Top 5 SQL Audiobooks

No time to learn SQL? What if I said you could learn while sitting in traffic or washing dishes? It’s possible thanks to SQL Audiobooks. Check out which ones you should listen to. I have been recommending various SQL books for a long time. If selected well, they can be a great complement to the knowledge gained in interactive online courses. If you haven't read my article yet, check it out.

How To Learn The SELECT Statement in SQL

When you think about learning SQL, one of the first things you come across is the SELECT statement. Selecting information is arguably the most important SQL feature. In this article, we’ll demonstrate the typical use cases for SQL SELECT with practical examples. Read this article if you’re a beginner database user and would like to know what SELECT can do for you. SQL, or Structured Query Language, is the programming language the IT world uses to communicate with databases.

Is Learning SQL for Free Worthwhile?

Everyone likes to get something for free, even when it comes to SQL courses. But is free always good? Find out how and where you can learn SQL for free – in a way that’s worth your time. Beginner-friendly database courses and SQL tutorials often promise to teach SQL fundamentals like SELECT, WHERE, GROUP BY, HAVING, and ORDER BY. These commands are the basis of a powerful set of skills for entry-level jobs in data analysis or databases.

What Is a DBMS?

Updated on: February 19, 2024 We generate vast quantities of data every day, and that data needs to be stored somehow. That’s where DBMSs come in handy. Find out what they are and how they relate to databases. If you go on a diet and simply want to keep track of your weight, you can probably use a piece of paper and a pencil. If you then want to chart your daily caloric intake, you’ll probably switch to something like a computer spreadsheet.

How to Learn SQL Fast

Updated on 11th Oct 2023. Are you in a rush to boost your data analysis capabilities? Dive into our comprehensive guide and learn SQL fast! You work with data every day, but you've had enough of how long it takes to process your giant table in Excel. The time has come for a much better tool: SQL! But how long does it take to learn SQL? In this article, I'll show you how to learn SQL fast and become the Vin Diesel of data – how to become the "

Top 10 Laptops for Learning SQL in 2020

If you want to learn SQL, you’re going to need a device that’s portable and powerful. I recommend a laptop. Here are the features you’ll need, as well as my picks for laptops to get you learning SQL in 2020! I must admit that browsing Amazon’s computer offers or entering any computer store can give you a headache. So many models, with so many options! They differ in components, workmanship, battery life, and screen size and resolution.

What Is a SQL Dialect, and Which one Should You Learn?

Updated on: September 12, 2023 SQL, standard SQL, SQL Server, MySQL, PostgreSQL, Oracle, … You’d like to learn SQL, but you feel overwhelmed with options and you don’t know where to start. We’ll explain what each of these terms mean and what this has to do with SQL dialects. Diving into the world of SQL dialects can feel like jumping into a deep pool without knowing how to swim. There's a ton of stuff to pick up!

Why Learn SQL for iOS and Android Development?

App and program development with iOS and Android is a huge and rapidly growing field in the software world. While some developers get through their careers knowing only their chosen development language, there are plenty of reasons to add SQL to that skill set. Here at LearnSQL.com, we are often asked: “why Learn SQL for iOS and Android development?” To answer that question, we’ve put together a little explanation about exactly why learning SQL makes sense for those in the app development space.

Listen to These 7 SQL Podcasts

Are you learning SQL online but craving more? If you're looking for a way to squeeze some sweet SQL knowledge into your day, try listening to a SQL podcast. Choose one of our picks and get ready to amp up your SQL game! If you're like me, you like to get deep into a topic. You’re practicing it whenever there’s an opportunity. Of course, It’s hard to make time. I cherish the days I’m able to sit down and just get some hands-on learning done.

How to Learn the SQL Syntax

Read about what SQL is, and choose the best way for you among a wide variety of possibilities for learning SQL and remembering its syntax. What Is SQL? “SQL” stands for “Structured Query Language,” and as it sounds, it is a language dedicated to querying a relational database. In practice, it is used for creating, designing, and managing a relational database. People use SQL to: Create sets of tables and rows Modify database tables and index structures Insert, update, and delete data Retrieve information from a database for a variety of uses such as analytics Relational databases consist of a set of tables containing rows and columns of data.

Is it Difficult to Learn SQL?

It’s the number one question asked by the students of SQL and those new to the IT world. Is it difficult to learn SQL? If you came here because you’ve been pondering that very same question, take some comfort in the fact that in no way are you alone. Even the idea of SQL can be intimidating to those of us without a tech background, but it doesn’t have to be that way.

How to Get the First Day of the Week in SQL Server

This is additional content for the LearnSQL.com course Customer Behavior Analysis in SQL Server. This interactive course will teach you how to analyze customer lifecycle in a SQL database in over 70 hands-on exercises. You will learn how to find out compare registration rates between periods of time, compute conversion rates in SQL, compare customer cohorts, analyze customer activity and customer churn over time. This course is essential for anyone doing customer analysis in their job.

Stay at Home and Learn SQL for Free with LearnSQL.com

Working remotely is a dream come true for some. You ditch commuting and have more time for the people you love and the things you enjoy. For others, it's a challenge to maintain their focus when there are new distractions. It's also an opportunity to invest the few gained hours in learning something new. Staying at home can be a time when you might find yourself busier than you've ever been, but not getting many things done, and worse, not learning what you planned to.

Difference between GROUP BY and ORDER BY in Simple Words

For someone who is learning SQL, one of the most common places to get stuck is when learning the GROUP BY command. GROUP BY and ORDER BY are two important keywords in SQL that we use to organize data. The difference between GROUP BY and ORDER BY is that ORDER BY is more simple than GROUP BY and is usually introduced early in an SQL course. Sometimes, people are quite confused over these two concepts (SQL ORDER BY vs.

Join us on Facebook–We Can Learn More Together

We are so happy that you have joined us to learn and develop your SQL skills! We want to invite you to a new Facebook group, We Learn SQL. It is a great place for anyone interested in meeting like-minded people who also want to learn about database-related concepts. Learning together is easier, don't you think? Joining this group is a great opportunity to begin sharing your learning experiences with others.

Grouping Data in SQL Server

People who work with data know that data grouping can sometimes be a chore. If you struggle and waste hours with Excel, OpenOffice, or some other tool trying to group various sets of data, take a look at this article and learn how to do the work much quicker and easier by using SQL. You often find yourself in a situation where you need to analyze data and present the results in a form other than the one in which the data is stored.

SQL Order of Operations

SQL is not a traditional programming language in which you write a sequence of instructions in a given order of execution. Instead, SQL is a "declarative" language, which means that by writing a SQL query, you declare what data you expect as a result of the query, but you don't indicate how to obtain it. Six Operations to Order: SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY By using examples, we will explain the execution order of the six most common operations or pieces in an SQL query.

The Most Important SQL Queries for Beginners

How do you get data from a table? How do you create or delete a table? How do you display distinct records? How do you select rows which store a specific value in a column? You can easily do all of this by writing basic SQL queries. This guide discusses the 30 most important SQL queries for beginners. Let's take a look. 1. Retrieving Data From All Columns This is a very basic query to display all data from a table.

YouTube Tutorials That Actually Teach You Some SQL

YouTube is not just funny cats, music clips, and viral videos. It can also be a mine of knowledge – if you know where to look. Can YouTube tutorials really help you learn SQL? Let's say you're a marketer or an accountant. You work with databases every day. But when it’s time to write a query and get specific data, you need to call someone from IT. Why not learn to do it yourself?

24 Rules to the SQL Formatting Standard

Writing queries to a database requires knowledge about SQL syntax, but this is not all you should know. Best practices for writing professional SQL code require good formatting skills. In this article I discuss why this is so important and what are the basic rules you should follow. Why is it Worthwhile to Format SQL Code? Beginner SQL programmers often don't pay much attention to formatting their code. If you think formatting is something that can be safely ignored, look at the code below:

SQL INNER JOIN Explained in Simple Words

In this article, I will cover perhaps the most important element of the SQL language. That's right! I'm talking about the SQL INNER JOIN clause. As you know, in a database the data are stored in several tables. In my last article, I covered how to create SQL queries when the data you need is in only one table. But what if the data you need is in two tables?

Forget About Excel, High Five With SQL

Find out why you should forget about Excel and start using SQL even if you're not an IT expert. We'll show you how easy it is to learn SQL, how it can make you work better, and how LearnSQL.com makes the learning process fun. "I Don't Deal With Data" We frequently hear the sentence above from people outside the IT industry. Well, it's not entirely true. Data is now almost everywhere.

14 Differences Between Standard SQL and Transact-SQL

In my last article, I roughly described how standard SQL differs from T-SQL and who should learn which. Now I'd like to focus on the syntax differences and illustrate these differences with examples. If you think T-SQL is an extension implementing all the features from standard SQL, you aren't right. However, in SQL Server you will find almost all the features of the SQL standard. In this article you will find examples of some of the differences in syntax between standard SQL and Transact-SQL.

What's the Difference Between SQL and T-SQL?

If you are beginning to learn SQL and are confused by the differences between standard SQL and other similar languages like T-SQL, this article will help make things clear. You’ll not only learn about the difference between SQL and T-SQL but also find explanations concerning which topics would be better to start learning first: standard SQL or something more specific like MS SQL Server. What is Standard SQL? SQL (Structured Query Language) is a basic ANSI/ISO standard programming language designed to operate on data stored in relational databases.

Learn SQL on Your Lunch Break

Do you think learning SQL will help you in your career? You are right. SQL is one of the easiest computer languages to learn. These days many non-IT employees have SQL skills and use them to extend their professional capacity. Moreover, more and more companies are encouraging their employees in non-IT areas (like sales, advertising, and finances) to learn and use SQL. One of the benefits of empowering employees with SQL skills is that once you answer one data question, the results will generate a new data question, and then perhaps a cascade of further data questions.

Microsoft SQL Server Pros and Cons

Thinking about using Microsoft SQL Server? If so, you’re in the right place. In this article, we’ll go over the pros and cons of Microsoft SQL Server and evaluate the platform from both a company’s and a data specialist’s perspective. What Is Microsoft SQL Server? Before diving into the pros and cons of Microsoft SQL Server, I’ll explain what it is. In technical terms, it is a relational database management system (RDBMS) developed by Microsoft.

Practical Ways to Improve the Performance of SQL Queries

Knowing how to improve SQL query performance is an important skill, especially when working with with large databases. In this article, you'll learn how to write more efficient SQL queries to get results faster. The biggest difference between SQL and other languages is that SQL is a non-procedural language. In a non-procedural language you specify the results that you need but not the methods used to get it. The advantage of a non-procedural language is that it is easier to write programs, therefore it is common for non-programmer business users to generate reports from SQL queries.

How SQL supports data-driven organization

Typical business users make decisions based on gut feelings, but this can't get them so far. In this article, we'll look at how learning to write basic SQL queries helps your company become a data-driven organization. Businesses face many decisions. Do we increase our advertising budget in one region or the other? Are certain products selling quickly enough? What we should do if they aren't? Most of these decisions are driven by intuition, but organizations that make the most business impact use data-driven decision-making.

Microsoft SQL Server 2017 Installation Step by Step

Microsoft SQL Server is one of the most popular professional database servers on the market. In this guide, I’ll show you all SQL Server 2017 installation steps to help you install it on the Windows operating system together with SQL Management Studio. If you want to learn T-SQL, the dialect of SQL used in SQL Server, check out our SQL from A to Z in MS SQL Server track.

How to Begin Running SQL Queries

In this article, I’ll explain how to run a SQL query to help you execute your first one. Let’s jump right in! Running SQL queries for the first time is not a complex task, but it can seem intimidating at first if you’re a complete beginner. But once you get past that initial roadblock, you’ll be able to focus on learning SQL and writing more interesting queries to meet your business needs.

SQL Indexing 101

Indexes are one of the most misused and misunderstood entities in physical database design. A good understanding of indexes and how they solve database performance problems is necessary for any database novice. In this article, we'll look at basic database indexes and their role in database development. To picture what an index is, consider a textbook. At the end of most textbooks is an index listing all the terms one can find in the text and the pages on which they appear.

How to Use a SQL Wildcard

SQL wildcard allows us to filter data matching certain patterns in SQL. We use SQL wildcards with the LIKE operator in the WHERE clause of a query to filter data. In this beginner’s article, we’ll look at everything you need to know about basic SQL wildcards. If you like playing cards, then you know that wildcards can substitute any other card in your deck. Similarly, SQL wildcards can substitute one or more characters.

Our Picks for 2020’s 7 Best Online SQL Schools

If you’re looking for the best online SQL courses but aren’t sure where to start, you’re in the right place. I evaluated the top 7 ranked SQL schools available online to help you find the right solution. While summer is a great time to relax and get away from work, it’s also an excellent opportunity to learn new skills – like SQL! Thanks to SQL schools putting their courses on the internet, learning new tech skills is super easy and you can choose from a variety of formats to suit your needs.

SQL Filtering 101

Sometimes, SQL queries return lots of data you don't need. In this article, we'll look at a simple example of filtering SQL queries to reduce the complexity of your data. The key to learning how to filter data in SQL is understanding the very basics of Boolean algebra. That's just a fancy term mathematicians use to describe expressions involving logical values (true/false) and their associated operators (and, or, not, etc.

Why Learn SQL Over the Summer

Think summer is reserved for flying to warm places and hanging out at the beach? Sure! But it's also a great time to learn new skills that you haven't had time for. If you recently graduated from high school and want to get a head start on computer programming for college, learning SQL over the summer is a great opportunity. You have nothing to lose and everything to gain—SQL is actually really easy to learn, especially with so much free time over the summer.

Improving Slow Query Performance: When Runtime Matters

As SQL users, we usually focus on writing queries that return correct results. However, there are more things to consider when you're writing a query; one of them is query performance. In this article, we'll look at some examples where query response time is critical. Scene One: 911 Call Center Let's suppose we're at a 911 call center, when the phone rings. One of the operators answers the call; a witness reports that a man has been shot.

Converting Subqueries to Joins

Not all queries are alike, especially in terms of performance. In this article, we'll look at how you can convert SQL subqueries to joins for improved efficiency. When should I use SQL subqueries? Great question! Unfortunately, there's no concrete answer. SQL beginners tend to overuse subqueries. Typically, once they find that SQL construction works in one situation, they try to apply that same approach to other situations. It's only natural.

Essential SQL Terms to Know for Beginners and Pros

Updated on: April 11, 2024 Working with databases can seem daunting to a non-technical person. Right away, you’re bombarded with new terms that make your head spin. Database, database instance, table, SQL and others are some of the basic terms that you need to understand just to have a normal conversation with your technical colleagues. In this article, we’ll explore some basic SQL database terminology you need to know to succeed.

Learn to Write a SQL Correlated Subquery in 5 Minutes

If you’re familiar with the famous Russian nesting doll, then SQL correlated subqueries should be a peace of cake to understand—subqueries are just queries nested within queries. An SQL subquery is often called an “inner” query; the main query is usually called the “outer” query. This article covers everything you need to know about correlated subqueries. What Exactly is a SQL Correlated Subquery? A correlated SQL subquery is just a subquery that is executed many times—once for each record (row) returned by the outer (main) query.

New LearnSQL.com Online Practice: SQL Practice Set

If you’re looking to retrieve any kind of information from a database, you need to speak its language. But querying databases is an art—and it demands practice. That’s why we created our SQL practice set: a pack of SQL online practice exercises meant to help you master your skills. We spend a lot of time not only developing new courses but also speaking with our users and learning what they expect from SQL online practice exercises.

How to Become a Database Analyst

Curious about becoming a database analyst? Maybe you've taken some database courses at university and they really struck a chord. Or maybe you learned online. Now you're thinking about making a career out of working with databases. Where would you start? What should you expect at each phase of your professional development? In this post, we'll explore the challenging and exciting world of databases analysis. We'll go from the very beginning of a career to the apex of professional success.

Extracting Data From a String: SPLIT_PART in PostgreSQL

Learn how to use split_part in PostgreSQL to extract data from strings. Quite often, we’d like to extract parts of a string when working with text values. A common example is when we have a full name and need to retrieve only the last name. In this article, we’ll examine how to do it using split_part in PostgreSQL, i.e. a string-related function that can be used to extract a substring.

How to Start Thinking in SQL

Thinking in SQL will help you understand what SQL queries do, how to create and change them, and how to create reports from the data you obtain. If you want to know how to write better SQL queries, you have to change the way you think about the code. One of the greatest skills you can have in SQL programming is the ability to change an existing SQL query so you get the results you need.

How to Remove Junk Characters in SQL

Unwanted characters in text data can be a bit of a pain, but there’s an easy way to fix them. Scroll down to learn how to remove junk characters in SQL in the easiest way! Sometimes, we’ll find unwanted characters inside our string data because our SQL queries didn’t work as expected. Moreover, these extra characters may sometimes be invisible, which really complicates things. In this article, we’ll examine some string-related SQL functions that can handle unwanted characters—visible or not!

How to Solve Capitalization Data Quality Issues

Misspelled names, typos, and text data quality issues in your database? Power up your queries! Use SQL string functions to address data quality issues related to capitalization. Sometimes, our SQL queries don't work as expected because of data quality issues. In this article, we will examine some string-related SQL functions that can correct data quality issues related to capitalization. We'll be using PostgreSQL in our examples, but similar functions are available in most database engines.

18 Useful Important SQL Functions to Learn ASAP

Updated on: October 30th, 2023 Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike.

How to Draw a Christmas Tree in SQL

You can use SQL to manipulate all kinds of data, from huge analytical queries to brief single-purpose statements. But you can also use SQL just for fun, without any business requirements stifling your creativity. So, get out your jolly hat and prepare to sing O Christmas Tree as we create some quirky art with plain old SQL. Today, we’re going to generate some holiday-themed ASCII art, just for fun. That’s right.

The SQL Coalesce Function: Handling Null Values

You may already know how to return null values in SQL. Now, we’re going to learn how to do the opposite. Though the SQL COALESCE function may seem complex, it’s actually very straightforward and useful. Let’s look at several examples of how the SQL COALESCE function can be used to work with NULL values in SQL. The Need for Coalesce in SQL Before we dive into the SQL COALESCE function in detail, you should understand how NULL values behave in expressions.

Analyzing Survey Data: Explore Results Using SQL

Excel is a powerful beast that lets you analyze complex data. Yet, operating on big chunks of data can sometimes be a daunting task. Let's take a look at how SQL can help. Today, we'll tackle a common problem with importing data to an SQL database, using a real-life example. Suppose your company conducted a survey on the most popular programming trends and preferences, striving to meet the expectations of its users.

SQL Date and Interval Arithmetic: Employee Lateness

Computing Tardiness: Date, Time, and Interval SQL Arithmetic In this article, we’re going to discuss some interesting operations we can perform with date-related data types in SQL. The SQL standard, which most relational databases comply with these days, specifies the date-related data types that must be present in relational databases. The most important of such data types are date, time, timestamp, and interval. Here’s a brief rundown of the differences between these data types:

SQL Hacks To Control Family Budget On Black Friday Weekend

If you’re in the US, chances are you’ve been eagerly awaiting the approach of Black Friday just as much as Thanksgiving. Though the shopping frenzy takes hold of nearly everyone, some people have to stick to their budgets and shop prudently. In this article, we’ll take a look at how generating an SQL report can help you track how much your family spent shopping on Black Friday. Storing Black Friday Purchases in a Database Before we can create an SQL report, we first need some data we can use.

SQL Window Functions By Explanation

In our previous post, we explained how SQL window functions work by example. We started with some very simple, basic functions. Let's extend it by explaining subclauses in window functions. SQL window functions are a great way to compute results from a set of rows rather than a single row. As you know from our first article, the "window" in window function refers to the set of rows. We showed you some examples of simple window functions like RANK and LEAD.

Long SQL Query vs. Recursive SQL Query

Recursion is one of the central ideas in computer science. We can define it as a method for solving problems where the solution of the problem depends on solving a smaller instance of a problem. If this sounds complicated do not fret, in this article we will learn about recursion in SQL that you can practice and deepen in Vertabelo Academy. Recursion is a way of solving hierarchical problems we find in data with common SQL.

An Illustrated Guide to Multiple Join

So far, our articles in the "An Illustrated Guide" series have explained several join types: INNER JOINs, OUTER JOINs (LEFT JOIN, RIGHT JOIN, FULL JOIN), CROSS JOIN, self-join and non-equi join. In this final article of the series, we show you how to create SQL queries that match data from multiple tables using one or more join types. Join Types in SQL Queries Before we start discussing example SQL queries that use multiple join types, let's do a short recap of the join types we've covered so far, just to be sure you understand the differences.

An Illustrated Guide to the SQL Non Equi Join

Did you know that in SQL, a join doesn’t have to be based on identical matches? In this post, we look at the SQL non equi join, which uses ‘non-equal’ operators to match records. We’ve already discussed several types of joins, including self joins and CROSS JOIN, INNER JOIN and OUTER JOIN. These types of joins typically appear with the equals sign (=). However, some joins use conditions other than the equals (=) sign.

An Illustrated Guide to the SQL Self Join

What is an SQL self join and how does it work? When should it be used? We’ll provide answers to those questions! In SQL, we can combine data from multiple tables by using a JOIN operator. JOIN has several variants; we’ve already discussed CROSS JOIN, INNER JOIN, and OUTER JOIN. Most of the time, these operators join data from two or more different tables. You can practice all the different types of JOINs in our interactive SQL JOINs course.

How to Track Down Duplicate Values in a Table

When it comes to information management, duplicates present one of the most common challenges to data quality. In this article, I'll explain how it is possible to find and distinguish duplicate names with the help of the SQL data programming language. I really like my maiden name. The reason I like it so much is because it's rare. My maiden name (first with last) provided a unique identifier on platforms such as LinkedIn, Facebook, Twitter and similar.

Four Reasons You Must Learn SQL in Data Science

Is SQL important for data science? It certainly is! This language can help you build a foundation for your analytical career. Let’s see how you use SQL in data science. Data science is hot right now. What if you could predict the next market crash? Or contain the spread of Ebola? Or accurately predict a health crisis months or even years before it happens? Data scientists are working hard on these kinds of projects, and they are earning healthy salaries in the process.

5 Reasons Why No One Should Be Afraid to Learn SQL

Updated on: September 17, 2023 Think SQL is just for tech experts? Think again. In this article, we'll bust some common myths and show you that anyone can learn SQL. Let's dive in and make SQL simple. In today’s world, even those in non-technical jobs need some technical skills. And you don’t have to be a hard-core nerd to get these skills. Everywhere you look, from marketing to management, a touch of tech knowledge can set you apart.

Referential Constraints and Foreign Keys in MySQL

Foreign keys and referential constraints allow you to set relationships between tables and modify some of the database engine’s actions. This beginner’s guide explains referential integrity and foreign key use in MySQL. One of the most important aspects of database usage is being able to trust the information you store. Database engines provide several features that help you maintain the quality of your data, like defining required columns as NOT NULL and setting an exact data type for each column.

An Illustrated Guide to the SQL OUTER JOIN

We’ve already discussed the SQL CROSS JOIN and INNER JOIN statements. It’s time to explore another: OUTER JOIN. What is it? How does it work? Let’s find out! If you’ve read our other posts, you know that you can link the data in two or more database tables using one of the many types of SQL join operator. Today, we’ll discuss the three kinds of OUTER JOIN: LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN.

An Illustrated Guide to the SQL INNER JOIN

What is an SQL INNER JOIN, and how does it work? Let's find out! In my last article, I discussed the CROSS JOIN operation in SQL. Today, we'll look at INNER JOIN and how to use it. Is it the same as a JOIN? How many tables can you link with an INNER JOIN? These are all good questions. Let's look at the answers! What is an INNER JOIN?

An Introduction to Using SQL Aggregate Functions with JOINs

Previously, we've discussed the use of SQL aggregate functions with the GROUP BY statement. Regular readers of the our blog will also remember our recent tutorial about JOINs. If you're a bit rusty on either subject, I encourage you to review them before continuing this article. That's because we will dig further into aggregate functions by pairing them with JOINs. This duo unleashes the full possibilities of SQL aggregate functions and allows us to perform computations on multiple tables in a single query.

SQL Set Operators: Union, Union All, Minus, Intersect

Ever heard terms such as union and intersection in SQL? They're examples of set operators, and they come in handy when you need to combine information from multiple tables or queries. In this article, we'll take a closer look at them. SQL queries let us choose the most important bits from large amounts of information. Of course, we can't expect that all necessary data will be stored in one table.

Learning JOINs With Real World SQL Examples

The JOIN statement lets you work with data stored in multiple tables. In this article, I’ll walk you through the topic of JOIN clauses using real world SQL examples. Imagine if you could only work with one database table at a time. Fortunately, this isn’t anything we have to worry about. Once you learn the JOIN statement, you can start linking data together. In this article, I’ll use real world SQL examples that illustrate how we use JOINs, how each type of JOIN works, and when to use each type.

Book Review: “Learn SQL the Hard Way” by Zed A. Shaw

“Learn SQL the Hard Way” by Zed A. Shaw is a great ebook for those who want to learn SQL essentials. At $19.99 USD, it may seem a bit expensive for an ebook, but you’re getting a DRM-free PDF, plus a whole bunch of explanatory videos and additional files. Who should read “Learn SQL the Hard Way”? Anyone interested in SQL basics – modifying databases or selecting information. Make no mistake about it: this book focuses heavily on the practical side of database language.

5 Books That Will Grow Your SQL Skills

Updated on: April 18, 2024 Looking to take your database skills up a notch? I've spent some time digging into various resources, and I want to share five advanced SQL books that really stood out. These texts are not just about learning the basics: they're about mastering the intricacies of SQL and truly enhancing your database management prowess. Whether you're troubleshooting complex queries or optimizing performance, these books provide insights that are both practical and transformative.

The Complete Beginner’s Guide to SQL Fundamentals

LearnSQL.com is a great place to learn SQL. If you’re a complete beginner, it’s best to have an overview of what SQL is, what a database is, and how they work together. In this article, you’ll find a complete guide to SQL fundamentals. SQL Fundamentals: Database Let’s begin our guide to SQL with basic definitions. You might have already heard that SQL is used with databases. What exactly is a database?

Refine Results with SQL Set Operators

Using UNION, UNION ALL, EXCEPT, and INTERSECT to manage SQL query results. The function of SQL set operators is pretty simple; they allow us to combine results from different SQL queries into one result set. The best way to understand how set operators work is to use visual methods like the Venn diagram. For those of you not familiar with Venn diagrams, they are two circles that represent items or collections of items.

Tag: Sql Books

The Best SQL Books for 2024

In 2024, finding the right resources to learn SQL is more important than ever. But with so many options out there, how do you choose the best one? In this guide, I will share some top SQL books to help you learn and master SQL this year. SQL, or Structured Query Language, is a tool that helps you work with data stored in databases; it lets you find and change information quickly and easily.

Tag: Sql Certificate

Top SQL Certificates in 2023

SQL is an essential skill in today’s data-driven world. Looking for the best SQL certificates to further your career can be confusing. This article gives some pointers that will help you make the best choice to fit your goals. Who needs an SQL certificate? If you can write advanced SQL queries, surely you can just demonstrate your skills at the interview and you'll be hired. Yes ... but ... you won't reach the interview unless the recruiter invites you.

Tag: Sql Challenge

New Monthly SQL Practice for April 2024!

In our April 2024 SQL Practice, you’ll meet Damien who manages a local art museum. He needs you to extract and present him with information to promote the museum. Will you use your SQL skills to help him? It should not be too hard if you have finished our SQL Basics course or otherwise understand core SQL concepts. Our interactive SQL course is a great way to test your skills and put what you have learned so far into practice.

New Monthly SQL Practice for March 2024!

Ready for our new SQL challenge? This time, we have prepared slightly more difficult SQL tasks. Here’s the March SQL Practice course! This time, you will help Lilia who runs a genetic testing clinic. She needs insight into the performance of her clinic for February 2024 and has hired you as an SQL specialist to help her out. Can you identify the most popular tests? Can you create a report on patient preferences by age?

New Monthly SQL Practice for February 2024!

In our February 2024 SQL Practice, you will meet Andrew. He is the manager of a ski resort in Tirol and needs help to get important insights from the database of his resort. He wants to find out how customers rate different slopes at his resort, which reviews are the best and the worst for the slopes, which slopes are the least popular, etc. Will you use your SQL skills to help him?

New Monthly SQL Practice for January 2024!

In our January 2024 SQL Practice, you’ll meet Julie. She is the owner of an online store where she sells handmade crochet items. She has hired you to help her with data analysis to grow her business. What are the best-selling products? Which products bring the most revenue? Can you create reports to help her with sales trends? You will find all the answers in the data. You just need to figure out how to get them out of the database using SQL.

New Monthly SQL Practice for December 2023!

In our December 2023 SQL Practice, you’ll meet John. He manages a website specializing in cooking recipes, tutorials, and articles. John needs you to extract and present information to help with further development of the website. Will you use your SQL skills to help him? It should not be too hard if you have finished our SQL Basics course or otherwise understand core SQL concepts. Our interactive SQL course is a great way to test your skills and put what you've learned so far into practice.

The Best SQL Practice Challenges for Beginners

Want to get better at SQL? Dive into SQL practice challenges! They're a great way to learn and improve. In this article, we'll explore why these challenges are important and where you can find the best ones. Are you a student, a business owner, or an employee? If data is part of your work and you want to learn SQL to manage it, you’ll need to practice. And interactive SQL challenges are ideal for beginners to get comfortable with the language.

New Monthly SQL Practice for November 2023!

Ready for our new SQL challenge? This time, we have prepared slightly more difficult SQL tasks. Here’s the November SQL Practice course! This time, you will help Emily, the owner of a local bike rental shop. She would like to gather data to help her grow the business and has hired you as an SQL specialist. Can you find out how many bikes the shop owns by category? Can you calculate the rental revenue for each month?

New Monthly SQL Practice for October 2023!

In our October 2023 SQL Practice, you meet Sophie. She manages an online business for publishing and printing books and needs you to access and present various statistics to help her grow her business. Can you use your SQL skills to help? It should not be too hard if you have finished our SQL Basics courses or otherwise understand core SQL concepts. Our interactive SQL course is a great way to test your skills and see if you can put what you've learned so far into practice.

New Monthly SQL Practice for September 2023!

Ready for our new SQL challenge? This time, we have prepared slightly more difficult SQL tasks. Here’s the September SQL Practice course! This time, you will help Evelyn, the owner of a local art gallery. She would like to gather data to grow her business and has hired you as an SQL specialist to help her out. Which art pieces have not been exhibited? What is the transportation cost for each art piece?

New Monthly SQL Practice for August 2023!

Are you an SQL beginner needing some interactive exercises to practice writing queries? Take the challenge and choose our August SQL Practice course. This is your next step towards becoming a pro. In our August 2023 SQL Practice, you meet Abigail, the manager of a local healthcare clinic. She needs you to help her gather the right statistics on the patients and the medical procedures they need. Use your SQL skills to help her find the data!

New Monthly SQL Practice for July 2023!

Ready for our new SQL challenge? This time, we have prepared slightly more difficult SQL tasks. Here’s the July SQL Practice course! You will help Isabella, the founder of an online home swap platform. On this platform, homeowners can find a place to stay for vacation by swapping homes with other homeowners. Isabella would like to gather data to help her expand the business, and she has hired you as an SQL specialist.

New Monthly SQL Practice for June 2023!

In our June 2023 SQL Practice, you’ll meet David. He manages an online pet store and needs you to find various statistics for further development. Can you use your SQL skills to help him? It shouldn’t be too hard if you have finished our SQL Basics course or otherwise understand core SQL concepts. Our interactive SQL course is a great way to test your skills and see if you can put what you've learned so far into practice.

New Monthly SQL Practice for May 2023!

Ready for our new SQL challenge? This time, we have prepared some slightly more difficult SQL tasks. Here’s the May 2023 SQL Practice course! You’ll be helping Sophie, who is running an online document editing app. She would like to gather some data that will help her to expand the business. She hired you as an SQL specialist to help her out. Can you find the average number of documents created by each user?

New Monthly SQL Practice for April 2023!

In our April 2023 SQL Practice, you’ll meet Emma, a host of game development tournaments called game jams. She needs your help in creating a reliable database structure and queries for the platform. Can you use your SQL skills to help her? It shouldn’t be too hard if you have finished our SQL Basics course or otherwise understand core SQL concepts. Our interactive SQL course is a great way to test your skills and see if you can put what you've learned so far into practice.

New Monthly SQL Practice for March 2023!

Ready for our new SQL challenge? This time, we have prepared slightly more difficult SQL tasks. Here’s the March SQL Practice course! This time, you will help Shelly who runs a coffee shop. Shelly would like to gather some data to expand the business and has hired you as an SQL specialist. Can you help her find the most popular menu items? Can you calculate the total revenue in December 2022?

New Monthly SQL Practice for February 2023!

Are you a SQL beginner that needs some interactive exercises to practice writing queries? Take the challenge and choose our February 2023 SQL Practice course. This is the next step towards becoming a pro. In our February SQL Practice, you’ll meet Hazel, the manager of a local gym. She needs your help to gather statistics on the gym members and the memberships they have purchased. Can you use your SQL skills to help her find the data?

New Monthly SQL Practice for January 2023!

Ready for our new SQL challenge? This time, we have prepared slightly more difficult SQL tasks. Here's the January SQL Practice course! This SQL Practice is at an advanced level and is aimed at those who have finished our SQL Basics and Window Functions course or otherwise have the equivalent knowledge. If you do not feel comfortable working with SQL window functions yet, make sure to check out these courses first and then come back here for more practice.

New Monthly SQL Practice for December 2022!

In our December 2022 SQL Practice, you will meet Lucas. He is a young entrepreneur and video game enthusiast. Lucas needs your help in creating queries and analyzing data for his gaming social hub, a place for people to buy and discuss games. Can you use your SQL skills to help him? It shouldn’t be too hard if you have finished our SQL Basics course and/or understand core SQL concepts.

New Monthly SQL Practice for November 2022!

You’re an SQL specialist helping Daisy, who is running a jewelry store. Daisy would like to gather some data that will help her expand the business. Can you find the number of purchases made by each customer? How much do the customers usually spend on a single purchase? The answers are hidden in the database – you just need to figure out how to get them out! This SQL Practice is at an advanced level and focuses on advanced GROUP BY queries.

New Monthly SQL Practice for October 2022!

In our October 2022 SQL Practice, you’ll meet Elisabeth, the manager of a music club. She needs you to help her gather the right statistics about the events organized in the club. Can you use your SQL skills to help her find the data? It shouldn’t be too hard if you have finished our SQL Basics course or understand core SQL concepts such as SELECT, WHERE, GROUP BY, HAVING, ORDER BY, and aggregate functions.

New Monthly SQL Practice for September 2022!

This time, you will help Kate who runs an electronics store. Kate would like to gather some data to help her expand her business. She has hired you as an SQL specialist to help her out. Can you find out the average number of purchases made by each customer? Can you calculate the prices for customers with loyalty cards? The answers are in the database. You just need to figure out how to get them out using SQL functions.

New Monthly SQL Practice for August 2022!

In our August 2022 SQL Practice, you’ll meet Anna, who manages a small private airline. She needs you to help her gather and analyze statistics on the company’s performance. Can you use your SQL skills to help her find the needed data? It shouldn’t be too hard if you have finished our SQL Basics courses or understand core SQL concepts. Our interactive SQL course is a great way to test your skills and see if you can put what you've learned so far into practice.

New Monthly SQL Practice for July 2022!

Ready for our new SQL challenge? This time, we have prepared slightly more difficult SQL tasks. Here’s July’s SQL Practice course! This time, you will help Ruby. She is the creator of a language tandem app, that is, a chat application in which learners can find native speakers for practicing languages. Ruby would like to gather data to help expand her business, and she has hired you as an SQL specialist to help her out.

New Monthly SQL Practice for June 2022!

Are you a SQL beginner that needs some interactive exercises to practice writing queries? Take up the challenge in our June SQL Practice course! In our June 2022 SQL Practice, you’ll meet Damiano – a young entrepreneur who wants to kick-start his car rental business. He needs you to help him gather the right data and statistics on his company’s performance. Can you use your SQL skills to help him find the data?

New Monthly SQL Practice for May 2022!

Ready for our new SQL challenge? This time, we have prepared some slightly more difficult SQL tasks. Here’s the May’s SQL Practice course! This time, you will be helping Tiffany, the owner of an online course website. She’d like to analyze her business data – it’s the perfect opportunity to use your SQL skills. Can you find the average number of students enrolled in a course? Calculate the average number of total hours spent by all students on a course?

New Monthly SQL Practice for April 2022!

Are you a SQL beginner that needs some interactive exercises to practice writing queries? Take up the challenge and choose our April SQL Practice course! In our April 2022 SQL Practice, you’ll meet Olivia, the owner of a hairdressing salon. She needs you to help her gather statistics on the services offered by her salon, the salon customers, their appointments, etc. Can you use your SQL skills to help her find the data?

New Monthly SQL Practice for March 2022!

If you are a more advanced SQL user who is comfortable using CASE WHEN, GROUP BY, aggregate functions, and common table expressions (CTEs), you can check your knowledge with the March SQL Practice. On LearnSQL.com, you‘ll find a new challenge to solve every month. Maybe this is the first time you’ve come across our Monthly SQL Practices. LearnSQL.com offers one SQL Practice each month: at the basic level on even-numbered months and at the advanced level on odd-numbered months.

New Monthly SQL Practice for February 2022!

Are you a SQL beginner that needs some interactive exercises to practice writing queries? Take the challenge and choose our February’s SQL Practice course. This is the next step towards becoming a pro. In our February 2022 SQL Practice, you’ll meet Keith – a rally (racing) fan who’s making a website dedicated to his favorite sport. He needs you to help him gather the right statistics on rally events, crews, results, etc.

New Monthly SQL Practice for January 2022!

Ready for our new SQL challenge? This time, we have prepared some slightly more difficult SQL tasks. Here’s January’s SQL Practice course! This time you will be helping Monica, the owner of an online store. She’d like to analyze her business data and earn more. It’s the perfect opportunity to use your SQL window functions skills. Can you find out how many customers she has in each country? Can you create reports to help her see sales trends?

New Monthly SQL Practice for December 2021!

If you are a more advanced SQL user who is comfortable writing complex JOINs, you can check your knowledge with December's SQL Practice. Every month on LearnSQL.com, you'll find a new challenge to solve. Maybe this is the first time you've come across our Monthly SQL Practices. LearnSQL.com offers one SQL Practice each month: basic levels on even-numbered months and advanced levels on odd-numbered months. Each SQL Practice takes about an hour to complete and contains 5–10 exercises to help you hone your skills.

New Monthly SQL Practice for November 2021!

If you are a more advanced SQL user who is comfortable writing complex GROUP BY statements, you can check your knowledge with November’s SQL Practice. Every month on LearnSQL.com, you‘ll find a new challenge to solve. Maybe this is the first time you’ve come across our Monthly SQL Practices. LearnSQL.com offers one free SQL Practice each month: basic levels on even-numbered months and advanced levels on odd-numbered months. Each SQL Practice takes about an hour (or less!

New Monthly SQL Practice for October 2021!

Do you have fundamental SQL knowledge? Do you know how to write basic SQL queries and join more than one table? If the answer is yes, you have a chance to test your knowledge by solving business problems with a new SQL Practice, available every month on LearnSQL.com. The October SQL Practice is at the basic level. You will check your SQL skills with data about a furniture store. Currently, the store operates only in Cleveland, Ohio in the U.

New Monthly SQL Practice for September 2021!

Do you know more advanced SQL than basic skills? Do you know how to write basic SQL queries, know functions that use different data types, work with text using special SQL functions, or convert data types without any problem? If your answer to these questions is yes, you have a chance to test your knowledge in solving business problems in the new SQL Practices, available every month on LearnSQL.com.

New Monthly SQL Practice for August 2021!

Do you have basic skills in SQL? Do you know how to write SQL queries? If the answer is yes, you can test your knowledge by solving business problems with our SQL Practice, available every month on LearnSQL.com. The August SQL Practice is at the basic level. You will check your SQL skills with data about a travel agency. The company organizes trips through different cities in the state of Illinois in the US, connecting its clients to many attractions.

New Monthly SQL Practice for July 2021!

If you are a more advanced SQL user who is comfortable writing complex JOINs, you can check your knowledge with July’s SQL Practice. Every month on LearnSQL.com, you‘ll find a new challenge to solve. Maybe this is the first time you’ve come across our Monthly SQL Practices. LearnSQL.com offers one free SQL Practice each month: basic levels on even-numbered months and advanced levels on odd-numbered months. Each SQL Practice takes about an hour (or less!

New Monthly SQL Practice for June 2021!

If you have fundamental SQL skills and know how to write queries, check out our new SQL Practice, available every month on LearnSQL.com. The June SQL Practice is for people who’ve mastered the basics of SQL. You’ll practice your SQL knowledge helping Jennifer with her dog sitting business – a service that brings together dog owners with people who can care for the pets when the owners are away.

New Monthly SQL Practice for May 2021!

Are you ready to use your SQL skills to write fundamental SQL queries that solve real-world problems? Do it with our new SQL Practice course on LearnSQL.com. The May SQL Practice is at an advanced level. Our main character this month, Luke, needs your help. You will test your SQL skills by using family tree data created by his brother. If this is the first time you've come across our monthly SQL Practices, here is some more information about them.

New Monthly SQL Practice for April 2021!

Are you ready to use SQL skills to write queries that resolve business problems? Give it a try in the new Monthly SQL Practice on LearnSQL.com. The April SQL Practice is for people with a basic level of SQL proficiency. You will test your SQL skills based on data about an apartment rental agency in Chicago, USA. If this is the first time you’ve come across our Monthly SQL Practices, you should know that LearnSQL.

New Monthly SQL Practice for March 2021!

Are you ready to use your SQL skills to create reports and help resolve business problems? You can do this with our new SQL Practice on LearnSQL.com! The March SQL Practice is at an advanced level. You will test your SQL skills by creating reports with data about language courses in the U.S. If this is the first time you’ve come across our Monthly SQL Practices, LearnSQL.com offers one free SQL Practice each month (at the basic level in the even months and at the advanced level in the odd months).

New Monthly Challenge for February 2021!

Are you ready to solve business problems using SQL in 2021 with a new Challenge on LearnSQL.com? The February Challenge is at a basic level. You will test your SQL skills with data about a rental car company in the U.S. If it is the first time you’ve come across our Monthly Challenges, LearnSQL.com offers one free SQL Challenge each month: at the basic level in the even months and at the advanced level in the odd months.

Monthly SQL Challenges in 2021

Did you know that LearnSQL.com provides a monthly SQL Challenge? Every month, we publish a new set of SQL practice exercises. Find out what to expect from our SQL challenges in 2021. Here at LearnSQL.com, we believe that the best way to learn SQL is through practice. After all, writing SQL is a practical skill. That’s why all our SQL courses (and there are over 30 of them!) are interactive: You learn SQL by writing SQL code.

New Monthly Challenge for January 2021!

This month’s LearnSQL.com Monthly Challenge is now available! In January, you can test your SQL skills in window functions by solving problems for Jeremy, the manager of the clothing retailer, Edward. Is this the first time you’ve come across our Monthly Challenge? LearnSQL.com delivers one SQL Challenge each month to our users. Starting in January 2021, we have monthly challenges separately for beginners and for advanced users. Each challenge contains 5 to 10 SQL exercises, prepared for those who want to practice their skills.

New Monthly Challenge for December 2020!

This month’s LearnSQL.com Monthly Challenge is now available! In December, you can test SQL skills by resolving problems for a group of co-workers who want to start a book exchange. Is this the first time you’ve met our Monthly Challenge? LearnSQL.com delivers one SQL Challenge each month to our users. Each challenge contains from 5 to 10 SQL exercises that were prepared for those who want to practice their skills.

New Monthly SQL Challenge for November 2020!

Are you ready for a new Monthly Challenge on LearnSQL.com? In November, we invite you to test your SQL skills as you learn about popular regional dishes in the USA. Is this the first time you’ve come across our Monthly Challenges? LearnSQL.com offers one free SQL Challenge each month. Each one contains from 5 to 10 SQL exercises that will help you practice your SQL skills. It takes about an hour (or less!

New Monthly SQL Challenge for October 2020!

The new Monthly Challenge on LearnSQL.com is ready! In October, we invite you to try your SQL skills by learning about job positions and recruitment agencies. Is this the first time you’ve come across our Monthly Challenge? LearnSQL.com delivers a new SQL challenge every month. Each challenge contains 5 to 10 SQL exercises designed for people who want to practice their SQL skills. It takes less than an hour to solve these tasks.

New Monthly Challenge for September 2020!

The new LearnSQL.com Monthly Challenge is ready! In September, we invite you to test your SQL skills to discover things about American movies, directors, and actors. Is this the first time you’ve come across our Monthly Challenge? LearnSQL.com delivers one Challenge per month, each a set of 5 to 10 SQL exercises prepared for those who want to practice their SQL skills. You won’t need more than an hour to solve these tasks.

New Monthly Challenge for August 2020!

A new month always brings new challenges. The August Monthly Challenge on LearnSQL.com is ready! This month, we invite you to support Mike in his first year of boarding school while testing your SQL knowledge. The SQL Challenge is a set of several exercises to help you practice your SQL skills. Each challenge is centered around a specific theme—food, stars, planets, travels, work, school, etc. The exercises within a challenge are interrelated, but you can do them in whatever order you want.

New SQL Monthly Challenge for July 2020!

The new LearnSQL.com Monthly Challenge is ready! In July, we invite you to sharpen your SQL skills with some questions about US states. If you’ve never come across our Monthly Challenge, it’s a set of 5 to 10 SQL exercises prepared for people who want to practice their SQL skills. Each challenge is designed around a specific theme. In this challenge, you’ll use SQL to learn facts about some US states.

Monthly SQL Challenges

SQL learners sometimes need challenges. Do you want to test your problem-solving skills or your knowledge of SQL? Then take our monthly SQL Challenges! We prepare them on LearnSQL.com every month. Each Challenge relates to a different interesting topic and will help you keep your SQL game sharp. In this article, you'll discover what our LearnSQL.com Monthly Challenges are and where to find them. We’ll also look at the Challenges collected in our Monthly SQL Challenge Mini Track.

New SQL Monthly Challenge for June 2020!

The new LearnSQL.com Monthly Challenge is ready! In June, we invite you to use your SQL skills to analyze insurance agency activities. Is this the first time you’ve ever come across our Monthly Challenge? Then you should know that it’s a set of 5 to 10 SQL exercises prepared for people who want to practice what they’ve learned. Each challenge is designed around a specific theme. In this seventh challenge, the exercises are built around a fictional insurance agency, but in the other challenges we’ve explored the subjects of pizza, the stars, a car workshop, and bakery management.

New SQL Monthly Challenge for May 2020!

The new LearnSQL.com Monthly Challenge is ready! In May, we invite you to use your SQL knowledge to help a bakery manager buy a new oven. Is this the first time you’ve ever come across our Monthly Challenge? Then you should know that it’s a set of 5 to 10 SQL exercises prepared for people who want to practice their SQL skills. Each challenge is designed around a specific theme.

New SQL Monthly Challenge for April 2020!

The new Monthly Challenge on LearnSQL.com is ready! In April, we invite you to test your SQL knowledge with data from another area of business: automobile repair. What is an SQL Challenge? It is a set of 5 to 10 SQL exercises, prepared for people who want to sharpen their SQL skills. Each challenge is centered around a specific theme. Do you like pizza? One of the challenges focuses on this miracle of Italian cuisine.

Tag: Sql Clauses

SQL Window Functions By Explanation

In our previous post, we explained how SQL window functions work by example. We started with some very simple, basic functions. Let's extend it by explaining subclauses in window functions. SQL window functions are a great way to compute results from a set of rows rather than a single row. As you know from our first article, the "window" in window function refers to the set of rows. We showed you some examples of simple window functions like RANK and LEAD.

An Illustrated Guide to Multiple Join

So far, our articles in the "An Illustrated Guide" series have explained several join types: INNER JOINs, OUTER JOINs (LEFT JOIN, RIGHT JOIN, FULL JOIN), CROSS JOIN, self-join and non-equi join. In this final article of the series, we show you how to create SQL queries that match data from multiple tables using one or more join types. Join Types in SQL Queries Before we start discussing example SQL queries that use multiple join types, let's do a short recap of the join types we've covered so far, just to be sure you understand the differences.

An Illustrated Guide to the SQL Non Equi Join

Did you know that in SQL, a join doesn’t have to be based on identical matches? In this post, we look at the SQL non equi join, which uses ‘non-equal’ operators to match records. We’ve already discussed several types of joins, including self joins and CROSS JOIN, INNER JOIN and OUTER JOIN. These types of joins typically appear with the equals sign (=). However, some joins use conditions other than the equals (=) sign.

An Illustrated Guide to the SQL Self Join

What is an SQL self join and how does it work? When should it be used? We’ll provide answers to those questions! In SQL, we can combine data from multiple tables by using a JOIN operator. JOIN has several variants; we’ve already discussed CROSS JOIN, INNER JOIN, and OUTER JOIN. Most of the time, these operators join data from two or more different tables. You can practice all the different types of JOINs in our interactive SQL JOINs course.

How to Track Down Duplicate Values in a Table

When it comes to information management, duplicates present one of the most common challenges to data quality. In this article, I'll explain how it is possible to find and distinguish duplicate names with the help of the SQL data programming language. I really like my maiden name. The reason I like it so much is because it's rare. My maiden name (first with last) provided a unique identifier on platforms such as LinkedIn, Facebook, Twitter and similar.

An Illustrated Guide to the SQL OUTER JOIN

We’ve already discussed the SQL CROSS JOIN and INNER JOIN statements. It’s time to explore another: OUTER JOIN. What is it? How does it work? Let’s find out! If you’ve read our other posts, you know that you can link the data in two or more database tables using one of the many types of SQL join operator. Today, we’ll discuss the three kinds of OUTER JOIN: LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN.

An Illustrated Guide to the SQL INNER JOIN

What is an SQL INNER JOIN, and how does it work? Let's find out! In my last article, I discussed the CROSS JOIN operation in SQL. Today, we'll look at INNER JOIN and how to use it. Is it the same as a JOIN? How many tables can you link with an INNER JOIN? These are all good questions. Let's look at the answers! What is an INNER JOIN?

An Illustrated Guide to the SQL CROSS JOIN

What is an SQL CROSS JOIN statement? When should you use it? When shouldn't you use it? This post will tell you what you need to know about CROSS JOIN. You already know that you can use the SQL JOIN statement to join one or more tables that share a matching record. And if you're read the LearnSQL's post Learning SQL JOINs Using Real Life Situations, you know that there are many types of JOINs.

Learning JOINs With Real World SQL Examples

The JOIN statement lets you work with data stored in multiple tables. In this article, I’ll walk you through the topic of JOIN clauses using real world SQL examples. Imagine if you could only work with one database table at a time. Fortunately, this isn’t anything we have to worry about. Once you learn the JOIN statement, you can start linking data together. In this article, I’ll use real world SQL examples that illustrate how we use JOINs, how each type of JOIN works, and when to use each type.

Tag: Sql Cookbook

MySQL Date Functions: Complete Analyst’s Guide

Master MySQL date functions and acquire a powerful tool to work with date and time information in your data analyses. Working with date and time data is an essential part of data analysis. Here are just three examples: Analyzing historical time series data is crucial for discovering trends and making reliable forecasts based on chronological information. Stock market analysis examines time series data extensively, especially when automated trading algorithms are employed.

SQL Cookbook with Recipes for Success

The internet holds a lot of information and can provide solutions to various problems. SQL users, both beginners and advanced, often turn to the internet for help with SQL queries. This article will help you find the right SQL queries to solve your problems. Learn what the SQL Cookbook is and why you should use it. You will also find a list of the most important recipes, from which you will prepare a great SQL dish with the taste of success.

Tag: Sql Course

The Best Way to Learn SQL: A Complete Guide for Beginners

If you've ever wondered about the best way to learn SQL, you're in the right place. Whether you're a complete beginner or an experienced professional looking to upskill, this comprehensive guide will show you the way. In today's data-driven world, you can think of data as a treasure chest full of gold. And SQL (Structured Query Language) is your personal key to unlocking it. SQL is a potent tool that allows you to communicate with databases, enabling you to extract, shape, and make sense of data.

We Have Changed For You!

It's even better than before! LearnSQL.com doesn't just have a new awesome look. We've also been working very hard on the "behind the scenes" stuff, and have changed many functions on our platform to ensure that you have the best possible learning experience. The first glance at the new LearnSQL.com platform shows immediately that a lot has changed. It was very good before, but now it's awesome! We are very proud of our new look and hope that it will make learning SQL even more fun and effective.

Tag: Sql Developer

7 Reasons Why AI Won't Replace SQL Developers

So you've heard all about AI and the famous ChatGPT. And you're wondering if these tools would be beneficial or detrimental to your profession. In this article, we will put your fears to rest and explain how SQL and AI can work together and make developers’ jobs easier. Let's start with an explanation of what Artificial Intelligence (AI) is. AI is an area of computer science concerned with creating machines capable of performing activities that would normally need human intelligence.

Common Entry Level SQL Developer Interview Questions

Have you ever been interviewed for an entry-level SQL position? Are you planning to apply for such a job? This article will help you to know what to expect and prepare for common SQL developer interview questions. After gaining some basic knowledge of SQL and programming, you're probably wondering what to do next. Or maybe you're not wondering! You know that what you've learned will soon disappear if you don't use it regularly.

How to Become an SQL Developer

There is no simple answer to the question “How do you become an SQL developer?” However, if the answer were too complex, there would be no point in writing this article, and yet I’m doing it. So, somewhere along the way, we’ll find the answer. As said in the intro, there is no magic wand that will turn you into an SQL developer. But reading this article will save you some time and help you focus on what is important to achieve your goal.

Tag: Sql Expressions

Using CASE to Add Logic to a SELECT

As you write an SQL query, you may need to get values from multiple columns and change values from one form to another. The simple way to achieve this goal is to add a CASE expression to your SELECT statement. In this article, we'll introduce you to the syntax, formats, and uses of the CASE expression. The CASE expression is a conditional expression: it evaluates data and returns a result.

Tag: Sql Flashcards

Here Are Our New SQL Flashcards

Preparing for an SQL exam or Data Job interview? Save these SQL Flashcards and always have them to hand, so you don’t forget anything during the most important moments. At LearnSQL.com, we understand that everyone has a unique learning style and pace. That's why we’ve created SQL Flashcards. They can help you during preparation for an exam or to consolidate your SQL knowledge. They are carefully crafted to help you reinforce your understanding of SQL concepts, syntax, and commands, making them an invaluable companion on your SQL learning journey.

Tag: Sql for Advanced

15 Tricky SQL Interview Questions for Experienced Users

SQL interview questions for experienced users usually contain some trick(y) questions. Interviewers use them to test your gumption, which is typically a result of extensive experience and a high level of SQL knowledge.  I will show you 15 tricky SQL interview questions (mostly coding) in this article. Mind you, these are not necessarily complex questions. Actually, that’s their main characteristic: they seem very easy and straightforward, but that’s the interviewer trying to deceive you.

How to Become a Database Analyst

Curious about becoming a database analyst? Maybe you've taken some database courses at university and they really struck a chord. Or maybe you learned online. Now you're thinking about making a career out of working with databases. Where would you start? What should you expect at each phase of your professional development? In this post, we'll explore the challenging and exciting world of databases analysis. We'll go from the very beginning of a career to the apex of professional success.

Statistics in SQL: Dependencies Between Discrete Variables

In my previous article, we looked at how you can calculate linear dependencies between two continuous variables with covariance and correlation. Both methods use the means of the two variables in their calculations. However, mean values and other population moments make no sense for categorical (nominal) variables. For instance, if you denote "Clerical" as 1 and "Professional" as 2 for an occupation variable, what does the average of 1.5 signify?

Simplify SQL Code: Recursive Queries in DBMS

Hey SQL users! Are you repeating the same query in every report? Are your queries getting too complicated? Use recursive queries to simplify SQL code! Too many SQL reports can lead to clutter on your desktop and in your head. And is it really necessary to code each of them separately? Ad-hoc queries can share much of the same SQL code with managerial reports and even regulatory reports. Suppose you’ve been writing basic SQL code for a while.

Common SQL Window Functions: Positional Functions

Positional SQL window functions deal with data's location in the set. In this post, we explain LEAD, LAG, and other positional functions. SQL window functions allow us to aggregate data while still using individual row values. We've already dealt with ranking functions and the use of partitions. In this post, we'll examine positional window functions, which are extremely helpful in reporting and summarizing data. Specifically, we'll look at LAG, LEAD, FIRST_VALUE and LAST_VALUE.

SQL Window Functions: Partitions and Ranking Functions

You’ve started your mastery of SQL window functions by learning RANK, NTILE, and other basic functions. In this article, we will explain how to use SQL partitions with ranking functions. Mastering SQL window functions (AKA analytical functions) is a bumpy road, but it helps to break the journey into logical stages that build on each other. In the previous Common SQL Functions article, you learned about the various rank functions, which are the most basic form of window functions.

SQL Window Function Example With Explanations

Interested in how window functions work? Scroll down to see our SQL window function example with definitive explanations! SQL window functions are a bit different; they compute their result based on a set of rowsrather than on a single row. In fact, the “window” in “window function” refers to that set of rows. Window functions are similar to aggregate functions, but there is one important difference. When we use aggregate functions with the GROUP BY clause, we “lose” the individual rows.

High Performance Statistical Queries –Skewness and Kurtosis

In descriptive statistics, the first four population moments include center, spread, skewness, and kurtosis or peakedness of a distribution. In this article, I am explaining the third and fourth population moments, the skewness and the kurtosis, and how to calculate them. Mean uses the values on the first degree in the calculation; therefore, it is the first population moment. Standard deviation uses the squared values and is therefore the second population moment.

Tag: Sql for Business

How to Use SQL to Calculate Customer Lifetime Value (LTV)

Working with data is an essential skill for marketers in today's data-driven world. As a marketer myself, I decided to create a series of articles about calculating key performance indicator (KPI) metrics for SaaS (Software as a Service) companies. We’ll start by calculating customer lifetime value (LTV) using SQL. Data is one of today’s most valuable resources. If you work in a SaaS company, you are flooded with a huge amount of data every day.

Tag: Sql for Students

Here Are Our New SQL Flashcards

Preparing for an SQL exam or Data Job interview? Save these SQL Flashcards and always have them to hand, so you don’t forget anything during the most important moments. At LearnSQL.com, we understand that everyone has a unique learning style and pace. That's why we’ve created SQL Flashcards. They can help you during preparation for an exam or to consolidate your SQL knowledge. They are carefully crafted to help you reinforce your understanding of SQL concepts, syntax, and commands, making them an invaluable companion on your SQL learning journey.

Tag: Sql Functions

SQL MAX Function

Learn about the SQL MAX function, which is used to find the highest value in your dataset. This article explains how to use the syntax of MAX function and shows typical usage examples. The SQL MAX function is an aggregate function that returns the maximum value in a column. MAX function, together with its counterpart MIN function, is useful for summarizing data in data analysis. It can help you to compute the range of values in a dataset.

Tag: Sql History

A Brief History of MS SQL Server

Microsoft SQL Server is one of the best database management systems in the world. It’s constantly improved and widely used. But do you know how it was created? In this article, I’ll show you the history of MS SQL Server, a solution that changed the world of databases. We’ll explore the stages of MS SQL Server development, find out how the current version differs from the original, and talk about where you can learn or practice SQL Server.

The History of SQL Standards

Has the SQL standard changed in the 30+ years it's been around? Absolutely! Learn about the journey from SQL-86 to modern SQL, today’s standard data language. SQL was created in the early 1970s by IBM. In 1974, Donald Chamberlin and Raymond Boyce published the article SEQUEL: A Structured English Query Language, which introduced SQL to the world. The article contained the BNF grammar (a detailed technical description of the language syntax) for the language, which IBM later thought was a mistake.

The History of SQL – How It All Began

Who created SQL and why? Find out in this article! Are you learning SQL? Or are you about to take the first step towards working with databases? Great decision! Either way, it's worth knowing the history of SQL – where it came from, who came up with it, and why. Here’s a brief history of SQL, starting with its foundational concept: the database. Ted Codd and the Relational Data Model The first computer databases appeared in the late 1960s.

Tag: Sql Index

What Is a Database Index?

Database indexes are critical to query speed and efficiency. Learn when, why, and how to use them – and when not to – in this post. Indexes are very important database objects; they optimize data access and improve database performance by helping the database execute SQL queries faster. Why not take this opportunity to learn how indexes work and how to create them? What Is a Database Index? Indexes are data structures that can increase a database’s efficiency in accessing tables.

Tag: Sql Interview Questions

SQL Interview Questions for Data Analysts

You have an upcoming interview for a data analyst position and SQL is one of the skills that will be tested. Well, these SQL questions for data analysts are specifically tailored for you! SQL is a must-have skill in every data analyst's toolkit. It simplifies data extraction and manipulation, allowing analysts to convert raw data into actionable insights. It enables analysts to perform ad hoc analyses, accelerating organizational decision-making processes.

15 Tricky SQL Interview Questions for Experienced Users

SQL interview questions for experienced users usually contain some trick(y) questions. Interviewers use them to test your gumption, which is typically a result of extensive experience and a high level of SQL knowledge.  I will show you 15 tricky SQL interview questions (mostly coding) in this article. Mind you, these are not necessarily complex questions. Actually, that’s their main characteristic: they seem very easy and straightforward, but that’s the interviewer trying to deceive you.

Top 29 SQL Server Interview Questions

Looking for an SQL Server job? Review these 29 must-know SQL Server interview questions and you’ll be well-prepared. And don’t worry about looking up the answers – we provide them, too! Microsoft SQL Server's first version was released in 1989 and has a rich history. It has come a long way since then, becoming one of the most used database engines in the data industry. In the last ten years, it’s been the third most popular database engine.

How to Become a Database Analyst

Curious about becoming a database analyst? Maybe you've taken some database courses at university and they really struck a chord. Or maybe you learned online. Now you're thinking about making a career out of working with databases. Where would you start? What should you expect at each phase of your professional development? In this post, we'll explore the challenging and exciting world of databases analysis. We'll go from the very beginning of a career to the apex of professional success.

Complete SQL Practice for Interviews

Congratulations! Your SQL skills were strong enough to get you that job interview! Now, if you only knew what SQL questions and practical exercises a recruiter might ask you to do… This article is meant as a SQL practice for interviews. I’ll help you prepare for the SQL and database aspects of your job interview. In a previous article, I explained how can you boost your career by learning SQL.

Finding the Perfect SQL Job

So you have some SQL skills and you're looking for a job that will use them. What are your options? SQL is everywhere, and there's a huge demand for people with database management skills. This is especially the case when companies start implementing Big Data solutions and strategies. There's no arguing that SQL is a must-have skill. If you're already proficient, how can you put your expertise to practical use in the job market?

A Day in the Life of a SQL Developer

What is a SQL developer? And what does a SQL developer do? Describing a “typical” day for a SQL developer is not easy. When your daily work is using various technologies to create interesting database-oriented products, very few days are alike! Each day brings a new and intriguing challenge. Nevertheless, I’ll have a go at explaining what everyday things a SQL developer might do. Morning: Arrive at Work What does a SQL developer do after arriving at the office?

Tag: Sql Job Market

Why Every Database Administrator Needs SQL

What is a database administrator? What do they do? Why do they need to know SQL, and what do they use it for? In this article, I'll answer these questions. As technology advances, more and more data is available to help organizations make informed decisions. You can't stay competitive – or provide good service to your customers – without the right information. Database administrators are responsible for making sure the right data is stored safely, that it's easily accessible to those who need it, and that it’s protected from malicious attacks.

This Is the Best SQL Assessment to Boost Your Career

What’s an SQL assessment and why would you need one? Where can you find a free and reliable gauge of your SQL skills? Find out in this article. In today's data-driven world, proficiency in SQL is more than just a skill—it's necessary. Whether you're looking to explore and analyze data to derive actionable insights or to store, manage, and optimize data in a relational database, having a solid foundation in SQL can significantly boost your resume.

Who Is a Data Manager?

Who are data managers? What are their responsibilities, and how do I become one? We’ll answer these questions and get you on your way to becoming a data manager! Simply put, data managers oversee the management of information or data within an organization. They manage data organization, storage, security, and accessibility, and they collaborate with other team members to guarantee data accuracy and usefulness in supporting decision-making. To ensure that data is effectively managed and used appropriately, they may also develop and implement policies and procedures pertaining to data management.

How to Become a Database Analyst

Curious about becoming a database analyst? Maybe you've taken some database courses at university and they really struck a chord. Or maybe you learned online. Now you're thinking about making a career out of working with databases. Where would you start? What should you expect at each phase of your professional development? In this post, we'll explore the challenging and exciting world of databases analysis. We'll go from the very beginning of a career to the apex of professional success.

Most Popular SQL Interview Questions for Business Analysts

SQL is an extremely desirable skill for anyone in today’s market—not just those in the IT sector. It’s becoming increasingly common for employers to require at least a basic knowledge of SQL in professions related to finance, statistics, banking, and business analytics. In this article, we will focus on the SQL interview questions for business analyst (BA) positions that appear at job interviews most often.. The best way to learn SQL is through practice.

The 5 Highest Paying Jobs That Use SQL

IT provides a wide and growing job market, offering many excellent opportunities in both career development and earning potential. Today we’ll take a look at several very interesting types of database jobs that use SQL. Every year, many in the work force set their sights and aim for new and better jobs. When it comes to jobs, “better” means different things to different people, but earning potential is almost always a top priority.

Four Reasons You Must Learn SQL in Data Science

Is SQL important for data science? It certainly is! This language can help you build a foundation for your analytical career. Let’s see how you use SQL in data science. Data science is hot right now. What if you could predict the next market crash? Or contain the spread of Ebola? Or accurately predict a health crisis months or even years before it happens? Data scientists are working hard on these kinds of projects, and they are earning healthy salaries in the process.

Complete SQL Practice for Interviews

Congratulations! Your SQL skills were strong enough to get you that job interview! Now, if you only knew what SQL questions and practical exercises a recruiter might ask you to do… This article is meant as a SQL practice for interviews. I’ll help you prepare for the SQL and database aspects of your job interview. In a previous article, I explained how can you boost your career by learning SQL.

Finding the Perfect SQL Job

So you have some SQL skills and you're looking for a job that will use them. What are your options? SQL is everywhere, and there's a huge demand for people with database management skills. This is especially the case when companies start implementing Big Data solutions and strategies. There's no arguing that SQL is a must-have skill. If you're already proficient, how can you put your expertise to practical use in the job market?

A Day in the Life of a SQL Developer

What is a SQL developer? And what does a SQL developer do? Describing a “typical” day for a SQL developer is not easy. When your daily work is using various technologies to create interesting database-oriented products, very few days are alike! Each day brings a new and intriguing challenge. Nevertheless, I’ll have a go at explaining what everyday things a SQL developer might do. Morning: Arrive at Work What does a SQL developer do after arriving at the office?

Tag: Sql Join

RIGHT JOIN in SQL: A Beginner's Tutorial

Learn RIGHT JOIN, a crucial command for any SQL specialist. Our article breaks down this essential technique, helping beginners effortlessly navigate and apply RIGHT JOIN in their database queries. In SQL, RIGHT JOIN (also known as RIGHT OUTER JOIN) is crucial for handling data effectively. This article is a beginner-friendly guide to the SQL RIGHT JOIN, an essential technique for merging different data tables. We'll walk you through the specifics of RIGHT JOIN, explaining how it stands apart from other join types in managing data.

Your Complete Guide to SQL JOINs (with Resources)

This detailed guide covers all important SQL JOIN topics, from basic concepts to advanced techniques. Bookmark this guide for future reference – it’s packed with useful resources and guides to help you work with JOINs effectively. SQL JOINs are essential in SQL and data analysis, as they let you combine data from different tables into a unified view. In this article, I've gathered everything you need to know about SQL JOINs.

5 Easy SQL INNER JOIN Examples for Beginners

Looking for a clear explanation of joins in SQL? Check out these five SQL INNER JOIN examples! In SQL, INNER JOINs can be a bit difficult for beginners to master. But once you start working with them, you’ll learn they’re very useful! Let’s discuss five examples of SQL INNER JOINs. But first, let’s do a quick review of why JOINs matter. In relational databases, data is organized and stored within tables.

What Is FULL JOIN in SQL? An Explanation with 4 Examples

What is FULL JOIN – one of the often neglected SQL join types? In this article, we’ll show you how useful FULL JOIN  can be and teach you how to apply it to different scenarios. The four examples cover some of the typical uses. An SQL join is a construction for combining data from two or more tables. FULL JOIN is one of the types of joins. You’ll get the most from this article if you’re already familiar with SQL joins and how they work.

SQL Joins: 12 Practice Questions with Detailed Answers

In this article, we dig into our SQL JOINS course and give you 12 join exercises to solve. But don’t worry – all the exercises have solutions and explanations. If you get stuck, help is there! This is, after all, made for practicing and learning.  SQL joins can be tricky. It’s not just the syntax, but also knowing what joins to use in what scenarios. Joins are used when combining data from two or more tables in SQL.

The Top 10 SQL JOIN Interview Questions with Answers

Have you ever wondered what SQL JOIN questions you might be asked in an interview? Do you feel prepared to answer them? This article covers the most common SQL JOIN interview questions and how to answer them. If you are applying for a job as a data analyst or software developer, you will likely be asked about your SQL JOIN knowledge. SQL JOIN clauses are a great topic for interviewers to quiz you on.

Tag: Sql Joins

What Are the Different SQL JOIN Types?

You just can’t understate the importance of the JOIN when learning SQL. Not only is it one of the most fundamental operations in relational databases, but it is also very versatile with many different types. Although SQL JOIN may be intimidating at first, it becomes a very handy instrument in your arsenal once you understand it. Let’s explore all the SQL JOIN types! We can safely say the JOIN operation is one of the most powerful features of SQL.

How to Keep Unmatched Rows From Two Tables in a SQL JOIN

Are you looking to join two tables in SQL without removing unmatched rows? Do you want to keep unmatched rows from one or both tables? In this article, I’ll explain how to keep all the records you want by using outer JOINs, such as LEFT JOIN, RIGHT JOIN, and FULL JOIN. Examples included! The SQL JOIN is a powerful tool that helps you combine data from multiple tables of your database.

How Do You Get Rid of Duplicates in an SQL JOIN?

Do you have unwanted duplicates from your SQL JOIN query? In this article, I’ll discuss the possible reasons for getting duplicates after joining tables in SQL and show how to fix a query depending on the reason behind the duplicates. Data analysts with little experience in SQL JOINs often encounter unwanted duplicates in the result set. It’s challenging for beginners to identify the reason behind these duplicates in JOINs.

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.

How to Keep Unmatched Rows When You Join two Tables in SQL

Learn how to use JOIN to keep both matched and unmatched rows when you join two tables. Joining two or more tables is a skill you need a lot if you’re working with databases. To review and practice your SQL joining skills, I recommend the interactive SQL JOINs course. It contains over 90 exercises and sections on different joining challenges. If you often join tables in SQL, you’ve probably noticed not all data from one table corresponds to data from another table all the time.

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.

What FULL JOIN Is and When to Use It

Learn about FULL JOIN, how to implement it, how it compares with the other types of SQL JOINs, and some of its unique use cases. Before we jump into FULL JOINs, let’s quickly recap what an SQL JOIN is. At its core, a JOIN combines data from two or more tables within a database. Tables are usually linked together using unique identifiers in each table, i.e. primary and foreign keys.

What Is LEFT JOIN in SQL?

Get to know the details of LEFT JOIN, one of the most common SQL JOIN types. SQL is mainly about getting data from databases. Very often, you’ll need data to be combined from multiple tables in your database. That’s when JOINs come into play. LEFT JOIN is one of the JOIN types that you are likely to use very often. In this article, I’ll explain the syntax of LEFT JOIN and how it works using several examples and illustrations.

SQL JOIN Cheat Sheet

Ready to master SQL JOINs? Get your downloadable cheat sheet now! Your shortcut to becoming an SQL JOINs expert is one click away. Dive deep into the world of SQL JOINs with our detailed SQL JOIN Cheat Sheet, a must-have resource for data enthusiasts at every level. Whether you are just starting out or looking to sharpen your skills, this guide is tailored to provide you with the quick reference needed to use SQL JOINs efficiently.

Tag: Sql Learning

Here Are Our New SQL Flashcards

Preparing for an SQL exam or Data Job interview? Save these SQL Flashcards and always have them to hand, so you don’t forget anything during the most important moments. At LearnSQL.com, we understand that everyone has a unique learning style and pace. That's why we’ve created SQL Flashcards. They can help you during preparation for an exam or to consolidate your SQL knowledge. They are carefully crafted to help you reinforce your understanding of SQL concepts, syntax, and commands, making them an invaluable companion on your SQL learning journey.

Tag: Sql Operator

SQL IN Operator

Why do you need to know SQL IN? Find out what you can do with this small but powerful operator. The IN operator is a fundamental tool in SQL, enabling data analysts and developers to filter and retrieve specific subsets of data from databases. While its basic usage may seem straightforward, mastering the nuances and advanced applications of the SQL IN operator can greatly enhance your SQL skills and lead to more powerful and optimized queries.

How to Use LIKE in SQL: SQL Pattern Matching

SQL pattern matching is a very important and useful ability. In this article, we look at how you can perform it using LIKE in SQL. SQL Pattern matching is a very simple concept. It allows you to search strings and substrings and find certain characters or groups of characters. Apart from SQL, this operation can be performed in many other programming languages. In this article, we’ll examine how you can use LIKE in SQL to search substrings.

Tag: Sql Operators

What Do the Operators LIKE and NOT LIKE Do?

The SQL LIKE and NOT LIKE operators are used to find matches between a string and a given pattern. They are part of standard SQL and work across all database types, making it essential knowledge for all SQL users. Gaining an understanding of these operators will allow you to write better queries and demonstrate to potential employers that you have the skills required to filter through expansive data sets.

Using AND, OR, and NOT Operators in SQL

AND, OR, and NOT are important logical operators in SQL. They help you combine the conditions used to filter records. They are most commonly used in conjunction with the WHERE or HAVING clauses. Furthermore, this topic is a pretty common SQL job interview question. To help you completely understand these operators, I’ll take you through some examples, fully explaining the syntax and purpose of each. Practicing using examples like these is one of the best methods for learning SQL.

Tag: Sql Patterns

Useful SQL Patterns: Date Generator

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. SQL patterns, such as the pivot pattern we discussed last week, can save you a lot of time and effort. Suppose you are asked to get a range of days in a financial quarter, but the only records you have are for the start and end dates of each quarter.

Useful SQL Patterns: Pivoting

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. The concept of pivot in SQL refers to taking the data in table rows and making that data into columns. This is very important in reporting, and it’s easy to do when you use the CASE statement.

Useful SQL Patterns: Matching Nulls by Masking Nulls

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. In database development, SQL developers often find themselves returning to the same SQL statements. Learning about these now, early in your SQL journey, will help you work more efficiently. Today, in the first post of this series, we will consider the match by null SQL pattern related to SQL data matching.

Tag: Sql Platform

We Have Changed For You!

It's even better than before! LearnSQL.com doesn't just have a new awesome look. We've also been working very hard on the "behind the scenes" stuff, and have changed many functions on our platform to ensure that you have the best possible learning experience. The first glance at the new LearnSQL.com platform shows immediately that a lot has changed. It was very good before, but now it's awesome! We are very proud of our new look and hope that it will make learning SQL even more fun and effective.

Tag: Sql Practice

Your Guide to SQL Practice at LearnSQL.com

Explore a variety of SQL practice opportunities at LearnSQL.com and take your data analysis skills to the next level. Whether you're a beginner or an advanced user, our learning resources are designed to help you master SQL through hands-on learning and real-world usage scenarios. SQL, or Structured Query Language, is a powerful tool used extensively in data analysis. It allows you to access and manipulate databases quickly and efficiently. Whether you are working in finance, healthcare, tech, or almost any other industry, SQL helps you extract and analyze data.

20 SQL Practice Problems for Beginner and Intermediate Users

Want to become an SQL expert? Try solving those 20 SQL practice problems! Whether you're just starting your SQL journey or preparing for exams, you need to sharpen your SQL skills if you want to become an expert. And you know what people say: practice makes perfect! Like most skills, SQL is best learned through experience; practicing SQL allows you to apply your knowledge to real-world scenarios. Through repeated practice, you'll gain the confidence to dive into complex SQL tasks and excel in both academic and professional fields.

18 SQL Questions for Beginners: Theory and Practice

Whether you're starting or refreshing your SQL skills, join us as we work through these 18 SQL practice questions for beginners. SQL, or Structured Query Language, is a programming language used to define, retrieve, and manipulate data in relational databases. It provides an intuitive syntax of SQL statements and keywords that create, modify, and query relational databases. This article focuses on reviewing and practicing the basics of SQL. We’ll start by reviewing the SELECT statement and its required and optional components for fetching data from a single table.

Free Course of the Month: Basic SQL Practice - Running

Kick off the new year and enhance your SQL skills with January’s free Course of the Month, Basic SQL Practice: Run Track Through Queries! As the new year unfolds, it's a time for reflection and the setting of new goals. A popular resolution among professionals and students alike is to acquire new skills or deepen existing ones. Whether it's learning a new language, mastering a software tool, or enhancing your job qualifications, the start of a new year provides a fresh opportunity for personal and professional growth.

Basic SQL Query Practice Online: 20 Exercises for Beginners

These 20 exercises are just what beginners need for SQL query practice. Try to solve each of them, and then look at the solutions. If something needs to be clarified, there are explanations for each solution. In this article, there’ll be less talking than usual. Instead, you’re going to write the answers to SQL practice queries. (Don’t worry; we’ve included the solutions if you get stuck.) The whole point is to give you, as a beginner, plenty of opportunities for SQL query practice.

SQL Subquery Practice: 15 Exercises with Solutions

Subqueries are often challenging for beginners. Practice makes perfect, so join us as we work through these 15 SQL subquery practice exercises! In SQL, a subquery is a query nested within another query. It simplifies building intricate queries to retrieve data that meets specific conditions from various tables. In this article, we present various ways of employing subqueries to create complex queries. We start by introducing SQL subqueries along with common use cases.

Free Course of the Month – Basic SQL Practice: A Store

This December, seize the opportunity to learn and practice SQL for free with our Basic SQL Practice: A Store course. Designed for an interactive and hands-on learning experience, this course starts with SQL basics and guides you through crafting queries that underpin business intelligence. Ready to get a grip on the fundamentals of SQL and dive into practical database management? Our December Course of the Month, Basic SQL Practice: A Store, is your perfect match!

SQL for Data Analysis: 15 Practical Exercises with Solutions

Are you new to the world of SQL and eager to unlock the power of data analysis?. In this article, we'll improve our SQL skills through 15 practical, hands-on exercises designed specifically for beginners. Because when it comes to SQL, practice truly makes perfect! We’re going to shine a spotlight on the critical domain of data analysis, where SQL takes center stage. SQL, or Structured Query Language, plays a pivotal role in data analysis.

The Best SQL Practice Challenges for Beginners

Want to get better at SQL? Dive into SQL practice challenges! They're a great way to learn and improve. In this article, we'll explore why these challenges are important and where you can find the best ones. Are you a student, a business owner, or an employee? If data is part of your work and you want to learn SQL to manage it, you’ll need to practice. And interactive SQL challenges are ideal for beginners to get comfortable with the language.

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.

SQL Practice for Students: 11 Exercises with Solutions

Calling all students! Are you SQL-curious? Want to learn or improve your SQL skills? This article has 11 SQL practice exercises with detailed solutions. Have you ever heard that “Practice makes perfect”? You probably have – that’s why you’re looking for SQL practice resources. If you want to develop strong skills or become an expert in a certain domain, you have to practice. As Rebecca McKeown wrote in her outstanding article Learning SQL?

Where to Practice SQL

Are you looking to boost your data management or analytical abilities? Then you need to know how and where to practice SQL, the worldwide language for managing and running relational databases. Of course, knowing where to practice SQL can be a challenge – there are so many options! In this article, we’ll walk you through the best digital platforms for enhancing your SQL skills. SQL, or Structured Query Language, is the universal language for managing and operating relational databases.

How to Prepare for the SQL Assessment Test

In this guide, I’ll walk you through the essentials of SQL assessment preparation, from understanding database management to mastering data analysis and SQL commands. Let’s dive in and set you on the path to success. In today's data-centric world, mastering SQL proficiency holds paramount importance. Whether you're a seasoned database manager or a newbie exploring the realm of database management, gearing up for an SQL Assessment is crucial. Stepping into the world of SQL can be both thrilling and challenging.

How to Create Your Own Database to Practice SQL

Welcome to the step-by-step guide to creating your own SQL database from scratch, designed with beginners in mind. This guide not only helps you set up your database but also introduces you to essential SQL practice exercises to get you started on your learning journey. Follow along to gain SQL hands-on practice and foster a deeper understanding of SQL functionalities. Set a solid foundation for more advanced SQL training!

Free Course of the Month: Blog & Traffic Data

Why practice SQL with real-life scenarios? We'll explain in this article – and we’ll show how you can do it for free during October 2023 with this LearnSQL.com course! SQL is the backbone of many data-driven applications and businesses. It's a powerful language that allows you to interact with databases, retrieve data, and make insightful decisions. If you're looking to improve your SQL skills, our Basic SQL Practice: Blog & Traffic Data course is the perfect opportunity.

11 SQL Window Functions Exercises with Solutions

In this article, we present 11 practice exercises involving SQL window functions, along with solutions and detailed explanations. SQL window functions are a powerful feature that lets us extract meaningful insights from our data easily, yet few SQL courses offer SQL window functions exercises. This makes practicing window functions quite difficult. In this article, we’ll give you 11 practice exercises that feature window functions. All exercises shown in this article come from our interactive courses Window Functions and Window Functions Practice Set.

SQL Joins: 12 Practice Questions with Detailed Answers

In this article, we dig into our SQL JOINS course and give you 12 join exercises to solve. But don’t worry – all the exercises have solutions and explanations. If you get stuck, help is there! This is, after all, made for practicing and learning.  SQL joins can be tricky. It’s not just the syntax, but also knowing what joins to use in what scenarios. Joins are used when combining data from two or more tables in SQL.

Free Course of the Month – SQL Practice Set in PostgreSQL

Do you know the basics of PostgreSQL but still need some practice? Look no further! Here is a great interactive course, SQL Practice Set in PostgreSQL. Throughout the month of September, you have access to it for FREE! We at LearnSQL.com believe that to learn a new skill, you need basic theoretical knowledge and, above all, a lot of practice. It's the same with writing PostgreSQL queries – you need a lot of PostgreSQL practice.

Advanced SQL Practice: 10 Exercises with Solutions

As SQL proficiency continues to be in high demand for data professionals and developers alike, the importance of hands-on practice cannot be emphasized enough. Read on to delve into the world of advanced SQL and engage in practical exercises to enhance your skills. This article provides you with a collection of ten challenging SQL practice exercises specifically for those seeking to enhance their advanced SQL skills. The exercises cover a selection of SQL concepts and will help you refresh your advanced SQL knowledge.

10 Beginner SQL Practice Exercises With Solutions

Solve these ten SQL practice problems and test where you stand with your SQL knowledge! This article is all about SQL practice. It’s the best way to learn SQL. We show you ten SQL practice exercises where you need to apply essential SQL concepts. If you’re an SQL rookie, no need to worry – these examples are for beginners. Use them as a practice or a way to learn new SQL concepts.

How to Practice Advanced SQL Online with LearnSQL.com

Want to go from intermediate to advanced SQL user? You’ll need to practice! Here are some ways you can practice advanced SQL online. You’ve seen how SQL helps you make data-driven decisions. Perhaps you’ve even learned some advanced features. But you’d like to become an expert—and for that, you need practice, practice, and more practice. Is it possible to get advanced SQL practice online? Taking SQL to the Next Level What is advanced SQL?

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!

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.

New Window Functions Practice Set Is Here!

Have you learned the SQL window functions? Or maybe, you forgot when and how to use them correctly? Are you preparing for an advanced SQL job interview? You've come to the right place! This is the new Window Functions Practice Set. This is very good news for all SQL learners and database professionals who want to improve their skills. The LearnSQL.com Team is proud to present the new Window Functions Practice Set!

Best Places to Practice SQL JOINs Online

You’ve just started your journey with SQL and you’re not sure what a JOIN is or where to use it. Don’t worry! In this article, you will find out what JOINs are and where you can practice them online. If you have just started learning SQL, you have a lot of topics to cover before you can call yourself a data professional. If you are serious about using SQL, you’ll have to understand JOIN – what it does, when you can use it, and what its different variants do.

Free Course of The Month – SQL Practice Set in MS SQL Server

You have to train a lot to learn a new skill. It is the same with MS SQL Server. Do you want to write good SQL queries? Or maybe you are preparing for a job interview? You've come to the right place! Throughout October you will have access to our amazing hands-on MS SQL Server course for FREE! You probably just thought: “There must be a catch. Why would someone give away SQL courses for free?

Why Is the SQL Practice Set my Favorite Online Course?

My friends know that I cannot sit still. I always have to do something, read something, and learn new stuff. It's stronger than me. But I don't complain, because this approach has only helped me in my life. I have done a ton of different online courses, but the SQL Practice Set has proved to be the best so far. Find out why. Learning SQL was not easy for me.

New Basic SQL Practice Course on LearnSQL.com

Hey, did you hear that there’s a brand-new Basic SQL Practice course on LearnSQL.com? This is a great opportunity to refresh your SQL, write some queries, and take your analytical skills to the next level. We’re proud to introduce Basic SQL Practice: A Store! Where did the idea for this new SQL practice course come from? From our users! They’ve let us know that they need more hands-on SQL exercises at a beginner level.

SQL Course of the Month – SQL Practice Set

Are you starting your adventure with SQL and looking for a place to practice your SQL queries? Or maybe you are preparing for a job interview? I have good news for you. Throughout May, you will have access to our amazing SQL practice course for FREE! Why is LearnSQL.com giving you a free SQL course? Every month, our users get the opportunity to take one of our great SQL courses for free.

SQL JOIN Topics That Require Practice

Are you interested in learning how to join tables in SQL? Where do you start? Many JOIN topics require practice. In this article, we’ll explore these topics by writing codes to solve real-life situations. Hopefully, you will learn which JOIN topics require attention. To make it easier for you, the topics are divided into beginner, intermediate, and advanced. Joining two or more tables in SQL lifts data analysis to another level.

SQL Training - Exercises That Will Help You Be Successful!

If you’re starting to dip your toes in the waters of learning SQL, you’ve probably been wondering about the best places to do your SQL training. We’ve rounded up exactly where to train for SQL and how to train for SQL so you can make some informed decisions about your learning journey. So how important is it to flex your SQL training muscles? Well, very. To be precise.

Where Can I Find Good Courses to Practice MS SQL Server?

Updated on: April 6, 2024 Begin your journey to mastering MS SQL Server with the finest practice exercises out there. Whether you are a beginner or seeking to improve your T-SQL skills, explore the top destinations for the most engaging and interactive MS SQL practice courses online. You've started learning MS SQL Server. Maybe you've done a course, watched some YouTube tutorials, and feel pretty confident in your knowledge. What now?

How Much SQL Practice Do You Need to Become a Pro?

Are you wondering how long it will take to learn and practice SQL before you can call yourself a pro? In this article, I will try to help you answer this question. Being a pro in SQL can mean many different things. Some people would say that being a professional is about mastery of advanced SQL, i.e. window functions or complex subqueries. For other people, being a professional means getting paid for your skills.

How to Practice PostgreSQL Online

PostgreSQL is hot right now!If you want to join a community of people passionate about data, this open-source database system is something you need to try. Like everything we teach on LearnSQL.com, PostgreSQL requires practice. To profit from Postgres – as this dialect is sometimes called – you need to start with the basics. You can watch some tutorials on YouTube or read articles to get to know what a Database Management System (DBMS) is.

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.

How to Practice SQL After a Video Course

Updated on: April 19, 2024 When you're just starting to learn coding, the most obvious first step is to watch online video courses. They're one of the most popular ways to learn the basics of a new technology without investing a lot of time and money. But you need to do more than that to master the topic. What should be your next step? When someone asks me about how to start learning to code, I often recommend trying video tutorials first.

How to Practice SQL JOINs

Updated on: November 7, 2023 There is no better way to learn how to practice SQL joins than through hands-on experience. However, there will probably be obstacles along the way. I’ll cover some of these obstacles and give ideas for how to overcome them. While this article won’t turn you into SQL JOINs expert, it will show you how to become one. So, let’s start! Diving into the world of databases?

Learning SQL? 12 Ways to Practice SQL Online

If you’re currently learning SQL, you may have found yourself knee-deep in reading material and may be wondering how on earth you can bridge the gap between book knowledge and real-life SQL application. In this article, we bring you 12 of the most effective ways to practice SQL online, taking you from a bookworm to a database butterfly in no time at all! All theory and no practice will make you a frustrated SQL user!

How to Practice SQL

Updated on: December 5th, 2023 Are you familiar with SQL's core concepts like aggregation functions, JOINs, GROUP BY, and ORDER BY? That's a great start. But to truly master SQL – especially for data analyst roles and job interviews – it's crucial to understand how to practice SQL effectively. This article provides a comprehensive guide to the best methods to practice SQL. You’re here because you're eager to enhance your SQL skills and become an independent database user.

New LearnSQL.com Online Practice: SQL Practice Set

If you’re looking to retrieve any kind of information from a database, you need to speak its language. But querying databases is an art—and it demands practice. That’s why we created our SQL practice set: a pack of SQL online practice exercises meant to help you master your skills. We spend a lot of time not only developing new courses but also speaking with our users and learning what they expect from SQL online practice exercises.

Tag: Sql Practice Guide

SQL Joins: 12 Practice Questions with Detailed Answers

In this article, we dig into our SQL JOINS course and give you 12 join exercises to solve. But don’t worry – all the exercises have solutions and explanations. If you get stuck, help is there! This is, after all, made for practicing and learning.  SQL joins can be tricky. It’s not just the syntax, but also knowing what joins to use in what scenarios. Joins are used when combining data from two or more tables in SQL.

Tag: Sql Puzzle

SQL Puzzle Day 2021

Do you like fun? This Friday, January 29 is National Puzzle Day, the perfect day to do a little brain exercise. We have prepared something special for you to mark this occasion. Join in with the game and get a big discount. The rules are simple. You have to put together a tough and fun jigsaw puzzle. We have hidden a promo code somewhere in the picture. Enter this code when purchasing our All Forever SQL Plan and you will get a $220 discount.

Tag: Sql Queries

Data Analyst's Guide to SQL Indexing: Fix Slow Queries

Does your SQL query response time leave something to be desired? Or maybe you don't know if your queries could be faster. In this article, we’ll explain how SQL indexing can help. Diving into SQL is like unlocking a superpower. It's all about mastering the art of querying your database effectively so you can retrieve the information you need quickly and easily. But what happens when you ask a question that's complex enough to slow response time from seconds to minutes – or even longer?

Data Export: From SQL Query to Spreadsheet

How do you export data from an SQL database to Excel or another spreadsheet? In this article, I’ll look at various methods and share a few tips for when things go wrong. SQL is the most widely used method of extracting data from a database. However, it’s not the only gadget in an analyst’s toolbox. Once the information is extracted, you’ll often want to import it into a spreadsheet – maybe to do further analysis or just to make it look pretty so you can present it to management.

SQL and Power BI: Transforming Data into Insights

The need for powerful tools that enable efficient data analysis and visualization has never been greater. Enter SQL and Power BI, a potent duo that enables businesses to maximize the value of their data assets. First, let’s explain what SQL and Power BI are; then we’ll discuss how and why they make such a great pair. SQL, or Structured Query Language, allows you to communicate with databases, making it the foundation of data management.

Where to Practice SQL

Are you looking to boost your data management or analytical abilities? Then you need to know how and where to practice SQL, the worldwide language for managing and running relational databases. Of course, knowing where to practice SQL can be a challenge – there are so many options! In this article, we’ll walk you through the best digital platforms for enhancing your SQL skills. SQL, or Structured Query Language, is the universal language for managing and operating relational databases.

How to Create Your Own Database to Practice SQL

Welcome to the step-by-step guide to creating your own SQL database from scratch, designed with beginners in mind. This guide not only helps you set up your database but also introduces you to essential SQL practice exercises to get you started on your learning journey. Follow along to gain SQL hands-on practice and foster a deeper understanding of SQL functionalities. Set a solid foundation for more advanced SQL training!

An SQL Basics Primer for Non-IT Professionals

You don’t need to be an IT professional to understand SQL. Our quick primer of SQL basics is perfect for beginners without any computer science or programming background. If you’ve ever tried to learn a new software program, you know it takes more than just a few minutes. But it doesn’t mean you can’t learn it! The same is true if you want to learn SQL and databases. Even if you don’t have an IT background, you can do it.

20 Basic SQL Query Examples for Beginners

These 20 basic queries are a must in a starter pack for every SQL beginner. These examples will get you going on your journey to mastering SQL. You’ve set your mind on learning SQL, googled ‘basic sql query examples’ or something similar, and here you are staring at this article. Now what? All learning starts with the basics, so let’s start with the most basic question: What Is SQL?

The Best Way to Learn SQL: A Complete Guide for Beginners

If you've ever wondered about the best way to learn SQL, you're in the right place. Whether you're a complete beginner or an experienced professional looking to upskill, this comprehensive guide will show you the way. In today's data-driven world, you can think of data as a treasure chest full of gold. And SQL (Structured Query Language) is your personal key to unlocking it. SQL is a potent tool that allows you to communicate with databases, enabling you to extract, shape, and make sense of data.

How SQL Skills Can Boost Your Resume

You may wonder: does having SQL skills matter? In what areas could I use my SQL skills? In this article, I will explain how having SQL skills can boost your resume and add momentum to your professional career. We are living in the Big Data era. Every time we go online, we provide the websites we visit with a lot of information. If we voluntarily give our data by creating an account, filling out a form, or making a purchase, we give them even more information.

SQL Window Functions By Explanation

In our previous post, we explained how SQL window functions work by example. We started with some very simple, basic functions. Let's extend it by explaining subclauses in window functions. SQL window functions are a great way to compute results from a set of rows rather than a single row. As you know from our first article, the "window" in window function refers to the set of rows. We showed you some examples of simple window functions like RANK and LEAD.

Tag: Sql Query

Enumerate and Explain All the Basic Elements of an SQL Query

“What are the basic elements of an SQL query?” is a popular SQL job interview question. In this article, we review the basic syntax of an SQL query. An SQL query, which requests information from a relational database, consists of several elements. These allow you to select specific columns from specific tables and to filter and sort this information if necessary. In this article, I’ll briefly review these elements by explaining what each element does and how to use it.

Tag: Sql Query Performance

Data Analyst's Guide to SQL Indexing: Fix Slow Queries

Does your SQL query response time leave something to be desired? Or maybe you don't know if your queries could be faster. In this article, we’ll explain how SQL indexing can help. Diving into SQL is like unlocking a superpower. It's all about mastering the art of querying your database effectively so you can retrieve the information you need quickly and easily. But what happens when you ask a question that's complex enough to slow response time from seconds to minutes – or even longer?

Improving Slow Query Performance: When Runtime Matters

As SQL users, we usually focus on writing queries that return correct results. However, there are more things to consider when you're writing a query; one of them is query performance. In this article, we'll look at some examples where query response time is critical. Scene One: 911 Call Center Let's suppose we're at a 911 call center, when the phone rings. One of the operators answers the call; a witness reports that a man has been shot.

Tag: Sql Rank

Our Picks for 2020’s 7 Best Online SQL Schools

If you’re looking for the best online SQL courses but aren’t sure where to start, you’re in the right place. I evaluated the top 7 ranked SQL schools available online to help you find the right solution. While summer is a great time to relax and get away from work, it’s also an excellent opportunity to learn new skills – like SQL! Thanks to SQL schools putting their courses on the internet, learning new tech skills is super easy and you can choose from a variety of formats to suit your needs.

Tag: Sql Reports

How to Use SQL to Filter Your Client Email Database

Looking for ways to be on friendly terms with your email database? Here's my way of using SQL to evaluate a promotion. A client database plays an essential role in developing your sales and marketing strategies. Having a clear and well-structured database has several benefits. For example, you can increase your company's revenue by managing your current and new clients – they can be monitored and offered special promotions. Moreover, such an effort develops customer satisfaction and increases value for your current customers.

Google Analytics and SQL

Google Analytics is a very popular tool among website and blog owners alike. With a simple and quick setup, it lets you gather data about your web page visitors easily. However, did you know that you can export data from Google Analytics to create your own SQL reports? Read this article to find out how. Google Analytics is an extremely popular and powerful solution that lets you collect and analyze various kinds of information about your website.

SQL Course of the Month – Creating Basic SQL Reports

In May, we chose Creating Basic SQL Reports as our course of the month. Why? Because the basis of every successful business is making the right decisions based on proven data and good SQL reports. I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, about this. She knows SQL better than just about anyone and is probably the best person to talk about SQL Reporting. What does it mean to create SQL reports?

Tag: Sql Scholarship

Stories of the LearnSQL Scholarship Program

2020 is behind us. It was an extremely difficult year: We’ve struggled with the Covid-19 pandemic, a worldwide economic crisis, and constant anxiety. Many people have lost their jobs and their prospects for a better tomorrow. That's why we decided to do something positive: establishing a SQL scholarship program. We decided to find people in difficult situations and try to help them. For many, learning SQL can be their chance to get a job and develop their career.

SQL Scholarship Program 2020

2020 is slowly coming to an end. It was extremely difficult for everyone. We’ve therefore decided to end it with something positive. This Holiday, we want to help someone change their life. Learn SQL will fund 50 SQL Scholarships for people who cannot afford to learn SQL and who may find it helpful in a difficult situation. We’ll hand out our flagship track - SQL From A to Z - for FREE!

Tag: Sql Server

Integrating SQL with Python for Data Analysis

Integrating SQL with Python isn’t difficult. The two tools work together to combine the information-processing power of relational databases with the flexibility of a programming language. In this article, I will discuss the benefits of data analysis using SQL and Python, with real-world coding examples. Why do most of the best data analysis tools on the market – such as Tableau and Power BI – include both SQL and Python in their toolboxes?

SQL Server Date Functions: A Data Analysis Guide

Date functions are the bread and butter of data analysis and reporting with SQL Server. In this guide, I will show you practical examples of the use of SQL Server date functions and how to apply them to your reports. A question for all data analysts: Do you want to be taken seriously? I’m sure you do. In that case, knowing SQL Server date functions is mandatory. Date and time data types are ubiquitous in databases, as they are essential for reporting.

Top 29 SQL Server Interview Questions

Looking for an SQL Server job? Review these 29 must-know SQL Server interview questions and you’ll be well-prepared. And don’t worry about looking up the answers – we provide them, too! Microsoft SQL Server's first version was released in 1989 and has a rich history. It has come a long way since then, becoming one of the most used database engines in the data industry. In the last ten years, it’s been the third most popular database engine.

SQL Server Cheat Sheet

Welcome to the SQL Server Cheat Sheet! Whether you're just starting out with SQL Server or you're a seasoned developer looking for a quick reference, this guide is tailored for you. This cheat sheet is a comprehensive guide to SQL Server, offering a quick reference to its essential commands. It covers the basics of creating and displaying databases and tables, the commands to modify tables, and the fundamental syntax for T-SQL commands such as SELECT, INSERT, UPDATE, and DELETE.

How to Learn T-SQL Querying

T-SQL is the dialect of SQL used by Microsoft SQL Server databases. Find out the best way to learn T-SQL querying with interactive online courses. In today's data-driven world, increasing your database knowledge is always a good choice. Microsoft SQL Server is one of the most popular databases nowadays. Knowing T-SQL – the query language of SQL Server databases –is often recommended as a worthwhile skill for careers in IT, business, or research fields.

How to Write a Recursive CTE in SQL Server

A guide to understanding and using recursive CTEs in SQL Server SQL Server offers a lot of powerful tools for working with data, including Common Table Expressions (CTEs). A CTE is a temporary named result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement. CTEs can break down long queries into smaller, more manageable pieces of logic and make them more readable. SQL Server offers recursive Common Table Expressions.

How to Export Data From Microsoft SQL Server to a CSV File

When working with data and databases, it is common to export data for further processing or transport to another database. Follow this article to learn how to export data from Microsoft SQL Server to a CSV file. In this article, we first recall what a CSV file is and why you would want to export data in this format from an MS SQL Server database. Then, we cut to the chase and export data to a CSV file using both SQL Server Management Studio (SSMS) and SQL Command Line (SQLCMD).

An Overview of Microsoft SQL Server Text Functions

Data analysts use text values when creating SQL reports. You can create your own labels with functions, classify rows based on text value, or do computations based on it. This article covers how to do all that. The text values in databases are not just for reading. As with numeric values, we perform operations on them and manipulate the text. SQL Server has a fair number of text functions.

Top 5 MS SQL Server Courses for Beginners

Every journey, including a career change, begins with the first step. If you're thinking about learning data analysis or strengthening your MS SQL Server skills arsenal, you've come to the right place. Here are the top 5 MS SQL Server online courses. Enjoy! You've probably heard that today’s organizations rely heavily on data analysis. You heard right. They are looking for employees who can navigate the world of databases and draw conclusions from data.

Free Course of the Month: SQL Reports in SQL Server

This is another in our series of free SQL Courses of the Month. This time, you can learn SQL Reporting in MS SQL Server for free. Do you want to be able to prepare even better SQL reports? Or maybe you have some basic knowledge of SQL Server (one of the major SQL dialects) and would like to go a step further? This is the course for you.

How to Group Data by Week in SQL Server

This is additional content for the LearnSQL.com course Customer Behavior Analysis in SQL Server. In this course, we showed you how you can analyze the customer lifecycle (customer acquisition, conversion, activity, retention, and churn) with SQL. We discussed customer registration cohorts, or groups of customers who registered during the same period (e.g. same week, same month). Analyzing customer registration cohorts lets you see registration trends and relate registration cohorts with marketing campaigns.

Grouping Data in SQL Server

People who work with data know that data grouping can sometimes be a chore. If you struggle and waste hours with Excel, OpenOffice, or some other tool trying to group various sets of data, take a look at this article and learn how to do the work much quicker and easier by using SQL. You often find yourself in a situation where you need to analyze data and present the results in a form other than the one in which the data is stored.

Grouping, Rolling, and Cubing Data

The first two articles in this series highlighted SQL Server's ability to organize data into user-defined windows and its aggregate functions. Part 3 will focus on other methods of aggregating and organizing data using built-in SQL Server features – specifically, its grouping functions. For consistency, the same base data will be used as in the first two parts of this series. CREATE TABLE WindowTable (WindowID INT IDENTITY, House Varchar(32), FullName Varchar(64), PhysicalSkill Decimal(4, 2), MentalSkill Decimal (4, 2)) GO

Window Functions: Part Two: Aggregating Data

In part one of this series on SQL Server window functions, the functionality of the OVER() clause was discussed. This article will focus on aggregate functions. The majority of these can be used in conjunction with OVER. Some, like SUM() and AVG(), are widely used. Others — including VARP() and CHECKSUM_AGG() — are not as well-known, but are potentially quite useful. OVER defines the user-specified range on which a function is applied.

Window Functions in SQL Server: Part One: The OVER() Clause

Window functions were first introduced in standard SQL 2003 and then extended in SQL 2008. Since SQL Server 2005, Microsoft has been steadily improving window functions in the database engine. These functions perform an aggregate operation against a user-defined range of rows (the window) and return a detail-level value for each row. Well-known aggregate functions include SUM, AVG, MIN, MAX, and many others. Recent versions of SQL Server have introduced ranking and analytic functions such as LAG, LEAD, RANK, CUME_DIST, and many others.

Basic Date and Time Functions in MS SQL Server

As a follow up to our article “The Most Useful Date and Time Functions in Oracle Database”, let’s review what date and time functions look like in MS SQL Server. Let’s start with functions that extract a year, month and day from a given date. declare @dt date = '2014-10-20' select year (@dt) as year, month (@dt) as month, day (@dt) as day SQL Server uses GETDATE() and SYSDATETIME() to get a current date and time.

Tag: Sql Set Operators

SQL Set Operators: Union, Union All, Minus, Intersect

Ever heard terms such as union and intersection in SQL? They're examples of set operators, and they come in handy when you need to combine information from multiple tables or queries. In this article, we'll take a closer look at them. SQL queries let us choose the most important bits from large amounts of information. Of course, we can't expect that all necessary data will be stored in one table.

Refine Results with SQL Set Operators

Using UNION, UNION ALL, EXCEPT, and INTERSECT to manage SQL query results. The function of SQL set operators is pretty simple; they allow us to combine results from different SQL queries into one result set. The best way to understand how set operators work is to use visual methods like the Venn diagram. For those of you not familiar with Venn diagrams, they are two circles that represent items or collections of items.

Tag: Sql String Functions

How to Draw a Christmas Tree in SQL

You can use SQL to manipulate all kinds of data, from huge analytical queries to brief single-purpose statements. But you can also use SQL just for fun, without any business requirements stifling your creativity. So, get out your jolly hat and prepare to sing O Christmas Tree as we create some quirky art with plain old SQL. Today, we’re going to generate some holiday-themed ASCII art, just for fun. That’s right.

Tag: Sql Study Tools

Here Are Our New SQL Flashcards

Preparing for an SQL exam or Data Job interview? Save these SQL Flashcards and always have them to hand, so you don’t forget anything during the most important moments. At LearnSQL.com, we understand that everyone has a unique learning style and pace. That's why we’ve created SQL Flashcards. They can help you during preparation for an exam or to consolidate your SQL knowledge. They are carefully crafted to help you reinforce your understanding of SQL concepts, syntax, and commands, making them an invaluable companion on your SQL learning journey.

Tag: Sql Subquery

Converting Subqueries to Joins

Not all queries are alike, especially in terms of performance. In this article, we'll look at how you can convert SQL subqueries to joins for improved efficiency. When should I use SQL subqueries? Great question! Unfortunately, there's no concrete answer. SQL beginners tend to overuse subqueries. Typically, once they find that SQL construction works in one situation, they try to apply that same approach to other situations. It's only natural.

Learn to Write a SQL Correlated Subquery in 5 Minutes

If you’re familiar with the famous Russian nesting doll, then SQL correlated subqueries should be a peace of cake to understand—subqueries are just queries nested within queries. An SQL subquery is often called an “inner” query; the main query is usually called the “outer” query. This article covers everything you need to know about correlated subqueries. What Exactly is a SQL Correlated Subquery? A correlated SQL subquery is just a subquery that is executed many times—once for each record (row) returned by the outer (main) query.

Tag: Sql Technologies

SQL Technologies Are More Common Than You Think

Where is SQL being used today? The answers might surprise you! (Hint: SQL technology is basically everywhere.) Is it worth learning SQL? After all, the language was created in the 1970s. Is it still relevant today? The list of technologies that support SQL is very long – and it’s growing. Read on to find out what kinds of programs use SQL. SQL in Databases Relational Databases = SQL Databases It’s no surprise that SQL is used in relational databases.

Tag: Sql Timestamps

The SQL Coalesce Function: Handling Null Values

You may already know how to return null values in SQL. Now, we’re going to learn how to do the opposite. Though the SQL COALESCE function may seem complex, it’s actually very straightforward and useful. Let’s look at several examples of how the SQL COALESCE function can be used to work with NULL values in SQL. The Need for Coalesce in SQL Before we dive into the SQL COALESCE function in detail, you should understand how NULL values behave in expressions.

SQL Date and Interval Arithmetic: Employee Lateness

Computing Tardiness: Date, Time, and Interval SQL Arithmetic In this article, we’re going to discuss some interesting operations we can perform with date-related data types in SQL. The SQL standard, which most relational databases comply with these days, specifies the date-related data types that must be present in relational databases. The most important of such data types are date, time, timestamp, and interval. Here’s a brief rundown of the differences between these data types:

Performing Calculations on Date- and Time-Related Values

Relational databases support several date and time data types. In this article, we'll look at several arithmetic operations we can do on these types. These operations are logical and understandable, even for the beginning SQL coder. Let's first briefly explain the main data types used for dates and times. Keep in mind that data types may differ by database engine, so check your database documentation for specifics before you start working with them.

Tag: Sql Wildcard

How to Use a SQL Wildcard

SQL wildcard allows us to filter data matching certain patterns in SQL. We use SQL wildcards with the LIKE operator in the WHERE clause of a query to filter data. In this beginner’s article, we’ll look at everything you need to know about basic SQL wildcards. If you like playing cards, then you know that wildcards can substitute any other card in your deck. Similarly, SQL wildcards can substitute one or more characters.

Tag: Sqlite

SQL Date and Time Functions in 5 Popular SQL Dialects

Are you confused by all the date and time functions used across different SQL dialects? In this article, I summarize the date and time data types used in PostgreSQL, Oracle, SQLite, MySQL, and T-SQL. I also provide examples with the key SQL date and time functions used across these dialects. It’s time to become date and time gurus! Do you want to calculate how often employees are running late for work?

How to Find the Difference Between Two Timestamps in SQLite

Problem: You have two columns of the type timestamp and you want to calculate the difference between them. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between the arrival and the departure. The travel table looks like this: iddeparturearrival 12018-03-25 12:00:002018-04-05 07:30:00 22019-09-12 15:50:002019-10-23 10:30:30 32018-07-14 16:15:002018-07-14 20:40:30 42018-01-05 08:35:002019-01-08 14:00:00 Solution 1 (difference in days): SELECT id, departure, arrival, JULIANDAY(arrival) - JULIANDAY(departure) AS difference FROM travel; The result is:

How to Calculate the Difference Between Two Dates in SQLite

Problem: You have two columns of the date type in SQLite database and you want to calculate the difference between them. Example: In the travel table, there are three columns: id, departure, and arrival. You'd like to calculate the difference between arrival and departure and the number of days from arrival to departure inclusively. The travel table looks like this: iddeparturearrival 12018-03-252018-04-05 22019-09-122019-09-23 32018-07-142018-07-14 42018-01-052018-01-08 Solution: SELECT id, departure, arrival, JULIANDAY(arrival) - JULIANDAY(departure) AS date_difference, JULIANDAY(arrival) - JULIANDAY(departure) + 1 AS days_inclusive FROM travel; The result is:

How to Group by Two Columns in SQL

Problem: You want to group your data by two columns so you can count some statistics. Example: In the order table, you have the columns order_date, product_id, customer_id, and number. You would like to count the number of products bought by each customer each day. The order table looks like this: order_dateproduct_idcustomer_idnumber 2023-11-25711 2023-11-251213 2023-11-265312 2023-11-26124 2023-11-26321 2023-11-261627 2023-11-26332 2023-11-27631 Solution: SELECT order_date, customer_id, SUM(number) AS products_number FROM order GROUP BY order_date, customer_id; The result is:

How to Get Yesterday’s Date in SQLite

Problem: You would like to display yesterday's date (without time) in an SQLite database. Solution 1: SELECT DATE('now','-1 day') AS yesterday_date; Assuming today is 2023-09-24, the result is: yesterday_date 2023-09-23 Discussion: To get yesterday's date, you need to subtract one day from today. Use DATE('now') to get today's date. In SQLite, you can subtract or add any number of days, months, etc.

How to Add a Month to a Date in SQLite

Problem: You would like to add one month to a given date in an SQLite database. Example: Our database has a table named production with data in the columns id, product, and start_date. idproductstart_date 1desk2019-08-17 2armchair2019-07-17 3sofa2019-10-31 Products have a new production start date that’s one month later than listed above. Let’s get the products’ names and their new start date.

How to Format a Datetime in SQLite

Problem: You want to format a datetime column or value in SQLite. Example: Our database has a table named ticket with data in the columns passenger_ID, train_number, and sale_datetime. passenger_IDtrain_numbersale_datetime 245NX45052019-10-17 12:56:30 127RG34032019-10-17 11:45:23 567FH45052019-10-18 12:40:32 230AP67002019-10-18 13:20:20 118BB34032019-10-18 13:13:13 For each ticket sale, let’s get the passenger ID, train number, and the sale date and time.

How to Get the Current Date in SQLite

Problem: You’d like to get the current date in an SQLite database. Solution: We’ll use the function DATE() to get the current date. SELECT DATE('now'); Here’s the result of the query: 2019-10-15 Discussion: The SQLite function DATE('now') returns the current date as a text value. It uses the YYYY-MM-DD format, where YYYY is a 4-digit year, MM is a 2-digit month, and DD is a 2-digit day of the month.

How to Get the Current Time in SQLite

Problem: You’d like to get the current time in an SQLite database. Solution: We’ll use the function TIME() to get the current time. SELECT TIME('now'); Here’s the result of the query: 10:56:12 Discussion: The SQLite function TIME() returns the current time as a text value. It uses the hh:mm:ss format, where hh is a 2-digit hour, mm is a 2-digit minute, and ss is a 2-digit second.

How to Concatenate Strings in SQL

Problem: You want to join strings from two columns of a table into one. Example: Our database has a table named student with data in the following columns: id, first_name and last_name. idfirst_namelast_name 1LoraSmith 2EmilBrown 3AlexJackson 4MartinDavis Let’s append the first name to the last name of the student in one string. Use a space between each name.

How to Filter Records with Aggregate Function AVG

Problem: You want to filter groups of rows in by the average value of a given column. Example: Our database has a table named product with data in the following columns: id, name, store and price. idnamestoreprice 1milkGreen Shop2.34 2breadClark’s Grocery3.56 3breadSuper Market4.15 4milkSuper Market1.80 5breadGrocery Amanda2.26 6milkViolet Grocery3.45 7milkClark’s Grocery2.10 8breadViolet Grocery2.

How to Filter Records with Aggregate Function COUNT

Problem: You want to find groups of rows with a specific number of entries in a group. Example: Our database has a table named product with data in the following columns: id, name and category. idnamecategory 1sofafurniture 2glovesclothing 3T-Shirtclothing 4chairfurniture 5deskfurniture 6watchelectronics 7armchairfurniture 8skirtclothing 9radio receiverelectronics Let’s find the category of products with more than two entries.

How to Filter Records with Aggregate Function SUM

Problem: You need to filter groups of rows by the sum of a given column. Example: Our database has a table named company with data in the following columns: id, department, first_name, last_name, and salary. iddepartmentfirst_namelast_namesalary 1marketingLoraBrown2300 2financeJohnJackson3200 3marketingMichaelThomson1270 4productionTonyMiller6500 5productionSallyGreen2500 6financeOlivierBlack3450 7productionJenifferMichelin2800 8marketingJeremyLorson3600 9marketingLouisSmith4200 Let’s find the names of departments that have sums of salaries of its employees less than 7000.

How to Filter Rows without NULL in a column

Problem: You want to find records without a NULL in a column. Example: Our database has a table named product with data in three columns: id, name, and price. idnameprice 1butterNULL 2milk2.35 3bread3.25 4cheeseNULL Let’s find the names and prices of products that have a price (without a NULL). Do this by using the IS NOT NULL operator.

How to Find Records with NULL in a Column

Problem: You want to find records with NULL in a column. Example: Our database has a table named children with data in four columns: id, first_name, middle_name, and last_name. idfirst_namemiddle_namelast_name 1JohnCarlJackson 2TomNULLThomson 3LisaAliceNULL 4AnneNULLSmith Let’s find the id, first name, and last name of children without a middle name (NULL in column middle_name). We use the IS NULL operator for this. Solution: SELECT id, first_name, last_name FROM children WHERE middle_name IS NULL; Here’s the result:

How to Find Rows with Maximum Value

Problem: You want to find rows which store the largest numeric value in a given column. Example: Our database has a table named student with data in the following columns: id, first_name, last_name, and grade. You want to find the students who have the highest grades. idfirst_namelast_namegrade 1LisaJackson3 2GaryLarry5 3TomMichelin2 4MartinBarker2 5EllieBlack5 6MarySimpson4 Solution: SELECT id, first_name, last_name, grade FROM student WHERE grade = (SELECT MAX(grade) FROM student); Here’s the result:

How to Find Rows with Minimum Value

Problem: You want to find rows which store the smallest numeric value in a column. Example: Our database has a table named weather with data in the following columns: id, city, and temperature. You want to find cities with the lowest temperature. idcitytemperature 1Houston23 2Atlanta20 3Boston15 4Cleveland15 5Dallas34 6Austin28 Solution: SELECT id, city, temperature FROM weather WHERE temperature = (SELECT MIN(temperature) FROM weather); Here’s the result:

How to Convert a String to Uppercase in SQL

Problem: You would like to convert a string to uppercase in SQL. Example: Our database has a table named questionnaire with data in the following columns: id, first_name, last_name, and favorite_car. idfirst_namelast_namefavorite_car 1AlanJacksonHonda Civic 2ElisaThomsonTOYOTA Camry 3MaryMartinesNissan rogue 4ChrisBrownford focus 5AdamSpringRam PICKUP Our table stores the make and model of the favorite car for each person who filled out our questionnaire.

How to Find the Average of a Numeric Column in SQL

Problem: You’d like to calculate the average of numbers stored in a column. Example: Our database has a table named sale with data in the following columns: id, city, year, and amount. idcityyearamount 1Los Angeles20172345.50 2Chicago20181345.46 3Annandale2016900.56 4Annandale201723230.22 5Los Angeles201812456.20 6Chicago201789000.40 7Annandale201821005.77 8Chicago20162300.89 Let’s calculate the average sales, regardless of city or year.

How to Find the Maximum Value of a Numeric Column in SQL

Problem: You’d like to find the maximum value of a numeric column. Example: Our database has a table named product with data in the following columns: id, name, year, and items. idnameyearitems 1bread roll2018345 2chocolate2017123 3butter201934 4bread roll2019456 5butter201856 6butter201778 7chocolate201987 8chocolate201876 Let’s find the maximum number of items sold over all years.

How to Find the Minimum Value of a Column in SQL

Problem: You’d like to find the smallest numeric value in a column. Example: Our database has a table named employment with data in the following columns: id, first_name, last_name, department, and salary. idfirst_namelast_namedepartmentsalary 1EllieMartinesmarketing1200 2MartinJohnsonfinance2300 3MichaelJacobsproduction1100 4StephenKowalskimarketing4300 5StanleyMillermarketing3500 6JenyBrownfinance5000 7MargaretGreenmarketing1500 8LisaThomasproduction2800 Let’s find the lowest salary among all employees.

How to Number Rows in SQL

Problem: You would like to give each row in the result table a separate number. Example: Our database has a table named furniture with data in the following columns: code (primary key) and name. codename 101bed 202sofa 333chair 123bookcase 235table 766desk The furniture table stores the name of pieces of furniture that we want to number.

How to Trim a String in SQLite

Problem: You’d like to remove spaces or a specific characters from the beginning and end of a string in SQLite. Example: Our database has a table named category with data in two columns: id and name. idname 1' sweets ' 2'meat ' 3' vegetables' Let’s trim the name of each category of products to remove the unnecessary space at the beginning and end.

What’s the Difference Between RANK and DENSE_RANK in SQL?

Problem: You want to compare the rankings produced by RANK and DENSE_RANK and add them as new columns to a table. Example: Our database has a table named sales_assistant with data in the following columns: id (primary key), first_name, last_name, month, and sold products. idfirst_namelast_namemonthsold products 1LisaBlack 52300 2MaryJacobs52400 3LisaBlack 62700 4MaryJacobs62700 5AlexSmith 62900 6MaryJacobs71200 7LisaBlack 71200 8AlexSmith 71000 Let’s display each sales assistant’s first and last name and number of sold products.

How to Add Rankings with DENSE_RANK() in SQL

Problem: You want to add a ranking position to rows consecutively, even if the rows have the same values. Example: Our database has a table named competition with data in the following columns: id (primary key), first_name, last_name, and score. idfirst_namelast_namescore 11JohnThomas345 14MaryJohnson222 16LisaBrown154 23AlanBlake222 32ChrisTaylor154 Let’s display all details about students: their last name, first name, and scores sorted by score in descending order.

How to Floor Numbers in SQL

Problem: You want to round a number down to the nearest integer. Example: Our database has a table named employee with data in the following columns: id, first_name, last_name, and hours_worked (for the current month). idfirst_namelast_namehours_worked 1AlanWatson95 2LisaBlack225 3LauraWilliams104 Let’s show the first and last name of each employee along with the number of days they worked.

How to Round Numbers in SQL

Problem: You want to round a number to a specific number of decimal places in SQL. Example: Our database has a table named product with data in the following columns: id, name, and price_net. idnameprice_net 1bread2.34 2croissant1.22 3roll0.38 Suppose there’s a tax of 24% on each product, and you’d like to compute the gross price of each item (i.e., after taxes) and round the value to two decimal places.

How to Round Up a Number to the Nearest Integer in SQL

Problem: You want to round up a number to the nearest integer in SQL. Example: Our database has a table named rent with data in the following columns: id, city, area, and bikes_for_rent. idcityareabikes_for_rent 1Los Angeles1302.151000 2Phoenix1340.69500 3Fargo126.44101 Let’s show each city’s name along with the ratio of its area to the number of bikes for rent.

How to Use LIKE in SQL

Problem: You need to search for specific patterns (certain combinations of letters or numbers) within text data in your database. We'll show you how to use the LIKE operator in SQL to: Find city names starting with S Find city names with exactly five characters Find city names starting with S and with o as the second-to-last character You'll also learn how to use LIKE and wildcard operators in SQL to find your own patterns in text data in your database.

How to Count the Number of Rows in a Table in SQL

Problem: You’d like to determine how many rows a table has. Example: Our database has a table named pet with data in the following columns: id, eID (electronic identifier), and name. ideIDname 123456sparky 223457mily 3NULLlessy 4NULLcarl 534545maggy Let’s count all rows in the table. Solution: COUNT(*) counts the total number of rows in the table:

How to Replace Part of a String in SQL

Problem: You’d like to replace part of a string with another string. Example: Our database has a table named investor with data in the following columns: id, company, and phone. idcompanyphone 1Big Market123–300-400 3The Sunny Restaurant123–222-456 4My Bank123-345-400 We’d like to change the phone number format for each company by replacing the hyphen character with a space.

How to Sum Values of a Column in SQL?

Problem: You’d like to sum the values of a column. Example: Our database has a table named game with data in the following columns: id, player, and score. idplayerscore 1John134 2Tom 146 3Lucy20 4Tom 118 5Tom 102 6Lucy90 7Lucy34 8John122 Let’s find the total score obtained by all players. Solution: SELECT SUM(score) as sum_score FROM game; Here’s the result:

How to Count Distinct Values in SQL

Problem: You’d like to count how many different non-NULL values there are in a given column. Example: Our database has a table named customer with data in the following columns: id, first_name, last_name, and city. idfirst_namelast_namecity 1JohnWilliamsChicago 2TomBrownAustin 3LucyMillerChicago 4EllieSmithDallas 5BrianJonesAustin 6AllanDavisNULL Let’s find the number of different (and non-NULL) cities.

How to Eliminate Duplicate Rows in SQL

Problem: You’d like to eliminate any duplicate rows from the result set of a query so that each row appears only once. Example: Our database has a table named clothes with data in the following columns: id, name, color, and year_produced. idnamecoloryear_produced 1T-shirtyellow2015 2jacketblue2016 3jeansblack2015 4jacketblue2015 5jacketgreen2016 6jacketyellow2017 7hatyellow2017 Let’s get the non-repeated names and colors of clothes produced before 2017.

How to Find Duplicate Rows in SQL?

Problem: You have duplicate rows in your table, with only the IDs being unique. How do you find those duplicate entries? Example: Our database has a table named product with data in the following columns: id, name, and category. idnamecategory 1steakmeat 2cakesweets 3steakmeat 4porkmeat 5cakesweets 6cakesweets Let’s find duplicate names and categories of products.

How to Join on Multiple Columns

Problem: You want to join tables on multiple columns by using a primary compound key in one table and a foreign compound key in another. Example: Our database has three tables named student, enrollment, and payment. The student table has data in the following columns: id (primary key), first_name, and last_name. idfirst_namelast_name 1EllieWillson 2TomBrown 3SandraMiller The enrollment table has data in the following columns: primary key (student_id and course_code), is_active, and start_date.

How to Multiply Two Columns in SQL

Problem: You want to multiply values from two columns of a table. Example: Our database has a table named purchase with data in the following columns: id, name, price, quantity, and discount_id. idnamepricequantitydiscount_id 1pen731 2notebook582 3rubber1131 4pencil case2423 Let’s multiply the price by the quantity of the products to find out how much you paid for each item in your order.

How to Order By Two Columns in SQL?

Problem: You need to display records from a given table sorted by two columns. Example: Our database has a table named employee with the following columns: id, first_name, last_name, and salary. idfirst_namelast_namesalary 1LisaUlman3000 2AdaMuller2400 3ThomasGreen2400 4MichaelMuller3000 5MaryGreen2400 Let’s display all information for each employee but sort the records according to salary in descending order first and then by last name in ascending order.

How to Order by Count in SQL?

Problem: You aggregated data into groups, but you want to sort the records in descending order by the number of elements in the groups. Example: Our database has a table named user with data in the following columns: id, first_name, last_name, and country. idfirst_namelast_namecountry 1LisaWilliamsEngland 2GaryAndersPoland 3TomWilliamsPoland 4MichaelBrownFrance 5SusanSmithUSA 6AnneJonesUSA 7EllieMillerPoland Let’s create a report on our users.

How to Order Alphabetically in SQL

Problem: You want to display records from a table in alphabetical or reverse-alphabetical order according to given column. Example: Our database has a table named customer. The customer table contains data in the id, first_name, and last_name columns. id first_name last_name 1 Susan Thomas 2 John Michael 3 Tom Muller Let’s display each customer’s information, sorted in ascending order by their last name.

MySQL's group_concat Equivalents in PostgreSQL, Oracle, DB2, HSQLDB, and SQLite

The GROUP_CONCAT() function in MySQL MySQL has a very handy function which concatenates strings from a group into one string. For example, let's take a look at the children table with data about parents' and children's names. if (typeof VertabeloEmbededObject === 'undefined') {var VertabeloEmbededObject = "loading";var s=document.createElement("script");s.setAttribute("type","text/javascript");s.setAttribute("src", "https://my.vertabelo.com/js/public-model/v1/api.js");(document.getElementsByTagName("head")[0] || document.documentElement ).appendChild(s);} parent_name child_name John Tom Michael Sylvie John Anna Michael Sophie To get the names of children of each person as a comma-separated string, you use the GROUP_CONCAT() function as follows:

Tag: Standard Sql Functions

18 Useful Important SQL Functions to Learn ASAP

Updated on: October 30th, 2023 Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike.

Learn SQL Views in 30 Minutes

Views aren't complicated – if you've got half an hour, we'll get you started writing SQL queries using views! Let's start by answering the question "What is a view in SQL?'. A view is a database object (as is a table, an index, or a stored procedure). Like a table, you can query a view and extract the information in it. It can be used in the FROM clause of a SELECT, and you can reference view columns in clauses like SELECT, WHERE and GROUP BY among other clauses as well.

Tag: Statistical Queries

Statistics in SQL: Dependencies Between Discrete Variables

In my previous article, we looked at how you can calculate linear dependencies between two continuous variables with covariance and correlation. Both methods use the means of the two variables in their calculations. However, mean values and other population moments make no sense for categorical (nominal) variables. For instance, if you denote "Clerical" as 1 and "Professional" as 2 for an occupation variable, what does the average of 1.5 signify?

Statistics in SQL: Centers of Distribution

My previous article explained how to calculate frequencies using T-SQL queries. Frequencies are used to analyze the distribution of discrete variables. Today, we’ll continue learning about statistics and SQL. In particular, we’ll focus on calculating centers of distribution. We’ll learn e.g. how to calculate the SQL median, what functions to use to calculate the SQL mode, and how to calculate various types of mean in SQL (geometric mean, harmonic mean and, of course, arithmetic mean).

Statistics in SQL: Calculating Frequencies & Histograms

Database and Business Intelligence (BI) developers create huge numbers of reports on a daily basis, and data analyses are an integral part of them. If you wonder whether you can perform statistical analysis in SQL, the answer is ‘yes’. Read my article to learn how to do this! Statistics are very useful as an initial stage of a more in-depth analysis, i.e. for data overview and data quality assessment. However, SQL statistical analysis possibilities are somewhat limited as there are not many statistical functions in SQL Server.

Tag: Statistics

Statistics in SQL: Dependencies Between Discrete Variables

In my previous article, we looked at how you can calculate linear dependencies between two continuous variables with covariance and correlation. Both methods use the means of the two variables in their calculations. However, mean values and other population moments make no sense for categorical (nominal) variables. For instance, if you denote "Clerical" as 1 and "Professional" as 2 for an occupation variable, what does the average of 1.5 signify?

High Performance Statistical Queries –Skewness and Kurtosis

In descriptive statistics, the first four population moments include center, spread, skewness, and kurtosis or peakedness of a distribution. In this article, I am explaining the third and fourth population moments, the skewness and the kurtosis, and how to calculate them. Mean uses the values on the first degree in the calculation; therefore, it is the first population moment. Standard deviation uses the squared values and is therefore the second population moment.

Statistics in SQL: Centers of Distribution

My previous article explained how to calculate frequencies using T-SQL queries. Frequencies are used to analyze the distribution of discrete variables. Today, we’ll continue learning about statistics and SQL. In particular, we’ll focus on calculating centers of distribution. We’ll learn e.g. how to calculate the SQL median, what functions to use to calculate the SQL mode, and how to calculate various types of mean in SQL (geometric mean, harmonic mean and, of course, arithmetic mean).

Statistics in SQL: Calculating Frequencies & Histograms

Database and Business Intelligence (BI) developers create huge numbers of reports on a daily basis, and data analyses are an integral part of them. If you wonder whether you can perform statistical analysis in SQL, the answer is ‘yes’. Read my article to learn how to do this! Statistics are very useful as an initial stage of a more in-depth analysis, i.e. for data overview and data quality assessment. However, SQL statistical analysis possibilities are somewhat limited as there are not many statistical functions in SQL Server.

Tag: String Functions

18 Useful Important SQL Functions to Learn ASAP

Updated on: October 30th, 2023 Learning a new programming language can seem intimidating. Like any other language, a programming language has a large vocabulary that you need to master. In this article, we’ll look at some of the most useful SQL functions that you need to know. Structured Query Language, commonly known as SQL, is the standard language for managing and querying data in relational databases. Born out of the need to efficiently interact with large datasets, SQL has become an indispensable tool for database administrators, data analysts, and developers alike.

Tag: String Manipulation

5 SQL Functions for Manipulating Strings

SQL functions used for manipulating strings, commonly called string functions, are among most important SQL’s tools. In this post, we’ll look at five ways you can perform various operations on strings. There are many SQL functions that let you “edit” string data. As you learn SQL, you’ll see how useful they prove. Some sql trim off unneeded spaces or characters; others tell you how long a string is. These functions give you a lot of opportunities to transform and work with strings, which makes your code more effective.

Tag: Subqueries

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.

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.

Tag: Subquery

SQL Subquery Practice: 15 Exercises with Solutions

Subqueries are often challenging for beginners. Practice makes perfect, so join us as we work through these 15 SQL subquery practice exercises! In SQL, a subquery is a query nested within another query. It simplifies building intricate queries to retrieve data that meets specific conditions from various tables. In this article, we present various ways of employing subqueries to create complex queries. We start by introducing SQL subqueries along with common use cases.

CTE vs. Subquery in SQL: What’s the Difference?

What are Common Table Expressions (CTEs)? Are they the same as subqueries? When would you need to use CTEs? This article looks at the similarities and differences between CTE vs subquery. When I introduce a student to Common Table Expressions, their first reaction is “That’s just a subquery! Why do I need to learn that?”. Let’s answer this question by looking at what you can do with an SQL subquery and what extra advantages there are in using a CTE.

5 SQL Subquery Examples

SQL subqueries are basic tools if you want to communicate effectively with relational databases. In this article, I provide five subquery examples demonstrating how to use scalar, multirow, and correlated subqueries in the WHERE, FROM/JOIN, and SELECT clauses. A subquery, or nested query, is a query placed within another SQL query. When requesting information from a database, you may find it necessary to include a subquery into the SELECT, FROM , JOIN, or WHERE clause.

Using Subqueries in INSERT, UPDATE, DELETE Statements

Did you know that subqueries can also be used in UPDATE, INSERT, and DELETE statements? Subqueries in SQL are like building blocks that can be used in a variety of statements, not just SELECT. If you find subqueries useful in SELECT, read this article to find out how useful they can be in other instructions. You will be able to create much more complex and powerful SQL queries in no time!

What’s an SQL Inline Query?

Have you ever heard the term “inline query”? How are they different from subqueries and derived tables? Have you looked this up in numerous places and still don’t know the answer? Let’s embark on a journey and find out together! The first time I heard the term “inline query”, I was a little bit surprised. It doesn’t sound like one of SQL’s nuances and I thought I knew all the basic concepts.

What Are the Different Types of SQL Subqueries?

Subqueries can be used in many business cases. What subquery types does SQL offer? And how can you use them efficiently? In this article, I’ll guide you through different subquery types and the typical situations when they are useful. What Is an SQL Subquery? A subquery, or nested query, is a query placed within another SQL query. There are many different scenarios where you may want to include a query in the WHERE, FROM, or SELECT clauses of your main query.

Subquery vs. JOIN

One of the challenges in writing SQL queries is choosing whether to use a subquery or a JOIN. There are many situations in which a JOIN is the better solution, and there are others where a subquery is better. Let’s consider this topic in detail. Subqueries are used in complex SQL queries. Usually, there is a main outer query and one or more subqueries nested within the outer query.

Subquery vs. CTE: A SQL Primer

Have you ever wondered about the differences between a subquery and a common table expression (CTE) in SQL? The concepts seem very similar, but knowing the difference – and when to use each one – will help you write efficient and readable queries. First, we’ll explain the concepts underlying subqueries and CTEs. Then we’ll look at a few examples and finally analyze the pros and cons of each technique.

Beginner’s Guide to the SQL Subquery

Subqueries are a powerful SQL resource, allowing us to combine data from multiple tables in a single query. In this article, we’ll teach you everything you need to begin using subqueries. Perhaps the simplest definition of a SQL subquery is “A query inside a query”. Subqueries are so easy to understand that they often appear in the opening chapters of SQL courses. However, there are many variants of subqueries that need to be explained.

What Is a Nested Query in SQL?

Have you ever wished that you could build a query with several SELECT statements? Good news! You can do this – and a lot more – with SQL’s nested queries. If you’ve been learning SQL (and maybe writing some queries) for a while, you’ve probably encountered cases where it looks like you need another SELECT statement inside your main statement. You may wonder “Is it possible to use nested SELECTs in SQL?

Correlated Subquery in SQL: A Beginner’s Guide

Sometimes, using a SQL correlated subquery is the only way to solve a statement. But these subqueries can be very slow. In this post, we’ll talk about when to use a correlated subquery, why, and how to do it. Subqueries are an important resource for increasing the expressive power of SQL. If you haven’t read our previous article, subqueries are simply a SELECT statement inside another SELECT. We can use them in different places inside a SELECT, such as in the WHERE, HAVING, or FROM clauses.

SQL Subqueries

The article describes what a subquery is and what these useful statements look like. We will cover basic examples with the IN, EXISTS, ANY, and ALL operators, look at subqueries in FROM and WHERE clauses, and explore the difference between correlated and nested subqueries. First, let’s start with an example database. To present some of these statements we need to have an example table and fill it with some data.

Tag: Sum

SQL SUM() Function Explained with 5 Practical Examples

Aggregate functions are an important part of SQL knowledge – and there’s no better place to start learning them than with the SUM() function. In this article, you can expand or refresh your SQL with 5 practical examples of SUM(). SQL allows us to do more than select values or expressions from tables. Most operations on relational databases use aggregate functions like SUM() to do computations on data.

Tag: Syntax

SQL Syntax

In today’s article, we’ll give you a walkthrough of core SQL syntax with a focus on the SELECT, INSERT INTO, UPDATE, and DELETE statements. SQL is a programming language designed specifically to communicate with databases. It allows you to get the data from a database or change the data within it. Like any programming language, SQL has a syntax you must adhere to. In other words, there are rules to follow regarding its commands if you want your code to work.

Tag: T Sql

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.

How to Learn T-SQL Querying

T-SQL is the dialect of SQL used by Microsoft SQL Server databases. Find out the best way to learn T-SQL querying with interactive online courses. In today's data-driven world, increasing your database knowledge is always a good choice. Microsoft SQL Server is one of the most popular databases nowadays. Knowing T-SQL – the query language of SQL Server databases –is often recommended as a worthwhile skill for careers in IT, business, or research fields.

SQL Date and Time Functions in 5 Popular SQL Dialects

Are you confused by all the date and time functions used across different SQL dialects? In this article, I summarize the date and time data types used in PostgreSQL, Oracle, SQLite, MySQL, and T-SQL. I also provide examples with the key SQL date and time functions used across these dialects. It’s time to become date and time gurus! Do you want to calculate how often employees are running late for work?

14 Differences Between Standard SQL and Transact-SQL

In my last article, I roughly described how standard SQL differs from T-SQL and who should learn which. Now I'd like to focus on the syntax differences and illustrate these differences with examples. If you think T-SQL is an extension implementing all the features from standard SQL, you aren't right. However, in SQL Server you will find almost all the features of the SQL standard. In this article you will find examples of some of the differences in syntax between standard SQL and Transact-SQL.

What's the Difference Between SQL and T-SQL?

If you are beginning to learn SQL and are confused by the differences between standard SQL and other similar languages like T-SQL, this article will help make things clear. You’ll not only learn about the difference between SQL and T-SQL but also find explanations concerning which topics would be better to start learning first: standard SQL or something more specific like MS SQL Server. What is Standard SQL? SQL (Structured Query Language) is a basic ANSI/ISO standard programming language designed to operate on data stored in relational databases.

Tag: Tables in Sql

Learn SQL Views in 30 Minutes

Views aren't complicated – if you've got half an hour, we'll get you started writing SQL queries using views! Let's start by answering the question "What is a view in SQL?'. A view is a database object (as is a table, an index, or a stored procedure). Like a table, you can query a view and extract the information in it. It can be used in the FROM clause of a SELECT, and you can reference view columns in clauses like SELECT, WHERE and GROUP BY among other clauses as well.

Tag: Text Functions

An Overview of SQL Text Functions in Google BigQuery

Data analysts and Google BigQuery go hand in hand. Google's cloud data warehouse presents you with plenty of opportunities for using standard SQL text functions you can't avoid in your day-to-day work as a data analyst. BigQuery uses Google Standard SQL, an ANSI-compliant SQL dialect. This means you can use standard SQL text functions in BigQuery without needing to learn a variant of a given function. The Standard SQL Functions course is an excellent resource for learning those functions.

An Overview of SQL Text Functions in MySQL

Do you work in MySQL as a data analyst? Then you should know how to use its text functions – data analysts don’t work only with numbers. Reporting requires computations, data classification, and label creation, and you can do all of that in MySQL.  In this article, I’ll explain several of the most common and useful MySQL text functions by discussing what they do and showing how they do it.

An Overview of Microsoft SQL Server Text Functions

Data analysts use text values when creating SQL reports. You can create your own labels with functions, classify rows based on text value, or do computations based on it. This article covers how to do all that. The text values in databases are not just for reading. As with numeric values, we perform operations on them and manipulate the text. SQL Server has a fair number of text functions.

The SQL Substring Function in 5 Examples

Working with text data in SQL? We explain how to get values from any point in a string. When you think of working with data in SQL, your first thought is probably a database full of numbers and your SQL code doing very fancy calculations. But text is data, too! It’s very common to find text data in databases. Not only do you have to extract it, but often you also have to manipulate it.

Tag: Time

Basic Date and Time Functions in MS SQL Server

As a follow up to our article “The Most Useful Date and Time Functions in Oracle Database”, let’s review what date and time functions look like in MS SQL Server. Let’s start with functions that extract a year, month and day from a given date. declare @dt date = '2014-10-20' select year (@dt) as year, month (@dt) as month, day (@dt) as day SQL Server uses GETDATE() and SYSDATETIME() to get a current date and time.

Tag: Tip

An Illustrated Guide to the SQL CROSS JOIN

What is an SQL CROSS JOIN statement? When should you use it? When shouldn't you use it? This post will tell you what you need to know about CROSS JOIN. You already know that you can use the SQL JOIN statement to join one or more tables that share a matching record. And if you're read the LearnSQL's post Learning SQL JOINs Using Real Life Situations, you know that there are many types of JOINs.

Tag: Tips

How Long Does It Take to Learn SQL?

Is it hard to learn SQL? How long does SQL mastery take? This article will answer those questions and get you started with the most useful SQL commands. How long does it take to learn SQL? If you’ve ever dabbled in Spanish or French, you know that learning a new language is tough and can take years. Luckily, mastering SQL is a much faster journey than conquering por/para or un, deux, trois.

5 SQL Functions for Manipulating Strings

SQL functions used for manipulating strings, commonly called string functions, are among most important SQL’s tools. In this post, we’ll look at five ways you can perform various operations on strings. There are many SQL functions that let you “edit” string data. As you learn SQL, you’ll see how useful they prove. Some sql trim off unneeded spaces or characters; others tell you how long a string is. These functions give you a lot of opportunities to transform and work with strings, which makes your code more effective.

How to Organize SQL Queries When They Get Long

The first long SQL query you’ll have to deal with is likely to be hard for you to structure and understand. These five tips will teach you the best way to organize SQL queries, i.e. write and format them. As we all know, SQL queries are essential to database management. Without them, it would be extremely difficult to find and work with the information in a database. Query length depends on the type of information we need and the size of the database.

Tag: Top Queries

Oracle Top-N Queries for Absolute Beginners

It's common to run a query using only part of a dataset – for example, the top 100 salespeople in a company. In this article, we'll see how to use Oracle's Top-N query method to query just these rows. Top-N queries retrieve a defined number of rows (top or bottom) from a result set. In other words, they find the best or worst of something – the ten best selling cars in a certain region, the five most popular routers, the 20 worst-performing stores, etc.

Tag: Track of the Season

SQL Track of the Season: SQL from A to Z in MS SQL Server

Maybe your company uses MS SQL Server and you’d like to join the data analysis team. Or maybe you want to add a new skill to your CV. Either way, our SQL Track of the Season: SQL from A to Z in MS SQL Server, will help. In this article, I’ll answer common questions about this awesome set of online MS SQL Server courses. If you’re reading this blog post, you probably already know that you should start learning SQL and working with databases.

Summer 2022 Track of the Season: Creating Database Structure

Summer is a great time to learn something new! Have you heard about data engineering? It’s one of today’s hottest skills. In this article, I'll show you why we selected our Creating Database Structures track as our SQL Track of the Season – and why it’s your ticket to a new career! LearnSQL.com offers online SQL training tracks – logically structured and well-thought-out learning paths that will help you work towards becoming an SQL expert.

Tag: Transaction

Useful SQL Patterns: Pivoting

As you start coding in SQL, you will use some statements and techniques over and over again. We call these “SQL patterns”. This series will look at the most common SQL patterns and consider how to use them. The concept of pivot in SQL refers to taking the data in table rows and making that data into columns. This is very important in reporting, and it’s easy to do when you use the CASE statement.

Tag: Union

UNION and UNION ALL in SQL Explained

In this article, we’ll explore the SQL clauses UNION and UNION ALL. Learn what they do and when to use each one. I had been an analyst for probably four years before I knew about the SQL clause UNION ALL. I used UNION on a regular basis, but had never heard of its counterpart. Then one day when I heard a coworker talking about it. I thought to myself, “What is he talking about?

UNION vs. UNION ALL in SQL: What’s the Difference?

UNION and UNION ALL are both used to retrieve records from multiple tables. This article will detail the differences between the two, allowing you to make the best choice for each unique scenario. You can use SQL’s UNION and UNION ALL commands to get data from multiple tables in your database. It’s a common use case, considering that most databases have many tables. Both UNION and UNION ALL are known as set operators.

Tag: Unique

What’s the Difference Between UNIQUE and DISTINCT in SQL?

We use the words unique and distinct interchangeably in our day-to-day life. However, these words play very different roles in SQL. Let’s find out what is so different about them and how we can use them in SQL. Despite the words unique and distinct being synonyms, they cover very different things in SQL. The UNIQUE keyword in SQL plays the role of a database constraint; it ensures there are no duplicate values stored in a particular column or a set of columns.

Tag: Unique Key

Primary Key vs. Unique Key: Explaining the Differences

When designing a database, we often need to decide between defining a primary key vs. a unique key. Both of them are crucial during the design and further phases of a database. They allow us to uniquely identify each row, ensure the uniqueness of values in the column(s), and more. Let’s take a deep dive to learn more. This article will go through the primary and unique keys, their functions, and features.

Tag: Update

Learn SQL Views in 30 Minutes

Views aren't complicated – if you've got half an hour, we'll get you started writing SQL queries using views! Let's start by answering the question "What is a view in SQL?'. A view is a database object (as is a table, an index, or a stored procedure). Like a table, you can query a view and extract the information in it. It can be used in the FROM clause of a SELECT, and you can reference view columns in clauses like SELECT, WHERE and GROUP BY among other clauses as well.

Using CASE with Data Modifying Statements

What happens when you combine CASE with SQL's data modifying statements? Find out in this article. The CASE expression is a very useful part of SQL and one that you'll employ frequently. We've already covered what the CASE expression does, how to format it, and how to use it in a SELECT statement in "Using CASE to Add Logic to a SELECT". Another article, "How to Sort Records with the ORDER BY Clause"

Tag: Video Tutorial

Best SQL Video Tutorials for 2021

Ready for this year’s picks for the best YouTube SQL video tutorials? Here are our top 5 choices! It's been well over a year since I last wrote about SQL tutorials on YouTube. Those seven channels can help you learn the basics of SQL quite painlessly, but now it's time to add to that list with 2021’s top contenders. Which YouTube SQL tutorials are worth your time and attention? I’ve got my favorites, but first, let’s consider an important question:

Tag: View

What’s the Difference Between SQL CTEs and Views?

SQL views vs. CTEs: What do they do? How are they different? Which one should you use and when? Get your answers here! In SQL, both CTEs (common table expressions) and views help organize your queries, leading to cleaner and easier-to-follow code. However, there are some important differences between them. This article will walk you through several examples of CTEs and views and explain when to use each one.

Tag: Where

SQL HAVING Clause: A Tutorial for Beginners

So, you're new to SQL and have just stumbled upon the HAVING clause. But what does it do? Why is it essential? In this article, we'll delve into the basics of the HAVING clause in SQL. And we’ll walk through practical exercises to enhance your understanding of its functionality. Let's start by defining Structured Query Language (SQL). SQL is a powerful and standardized programming language designed specifically for managing and manipulating relational databases; simply put, it is how we communicate with the databases that hold all of our important data.

How to Use WHERE with GROUP BY in SQL

In this article, we’ll discuss how to combine the WHERE and GROUP BY clauses in SQL. If you’re writing SQL on a daily basis, you will quickly realize how often both WHERE and GROUP BY clauses are used. WHERE is an essential part of most queries. It allows you to filter large datasets to only the pieces you are interested in. GROUP BY is one of the most powerful tools an analyst has when aggregating data.

How to Use Aggregate Functions in WHERE Clause

Filtering data according to the result of an aggregate function is a common data analysis task. So how do you use aggregates in the  WHERE clause? We’ll dedicate this whole article to answering that question.   Combining aggregate functions and filtering based on their results is often used in data analysis – e.g. showing branches with total sales above X,  countries where the number of posts is lower than Y, students with an average score below Z, and so on.

The Complete Guide to the SQL WHERE Clause

Learn how to use the SQL WHERE clause to filter rows. In this comprehensive article, we cover comparison operators and the BETWEEN, IN, LIKE, AND, OR, and NOT operators. Filtering output rows is one of the first things you need to learn when starting your SQL journey. In this guide, we’ll see how to use the SQL WHERE clause to filter rows in different scenarios. We’ll cover basic and some more advanced use cases.

How to Write a WHERE Clause in SQL

We explain how to use the SQL WHERE clause with practical examples. If you have just started learning SQL and want to know how to retrieve or work with only a specific portion of the data stored in your tables, then this article is for you! The SQL WHERE clause is something you must master if you wish to use SQL for working with data. It is arguably one of the most basic and must-learn constructs of SQL.

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.

Using AND, OR, and NOT Operators in SQL

AND, OR, and NOT are important logical operators in SQL. They help you combine the conditions used to filter records. They are most commonly used in conjunction with the WHERE or HAVING clauses. Furthermore, this topic is a pretty common SQL job interview question. To help you completely understand these operators, I’ll take you through some examples, fully explaining the syntax and purpose of each. Practicing using examples like these is one of the best methods for learning SQL.

What Is the SQL WHERE Clause?

The WHERE clause is a fundamental part of SQL. This clause filters results and applies conditions to SQL queries. It is most commonly used alongside the SELECT statement. If you’re a complete newcomer to this topic, you can learn the basics of SQL, including WHERE, in our SQL Basics course This article will clearly explain how to use WHERE in a SQL query. After reading it, you’ll have the confidence and knowledge to integrate WHERE into your daily work.

Why Window Functions Are Not Allowed in WHERE Clauses

Window functions are extremely powerful, but there are a lot of nuances and little details you need to learn about using window functions in order to use them correctly and efficiently. A fairly common question SQL users have is why window functions are not allowed in WHERE. TL;DR: You can use window functions in SELECT and ORDER BY. You cannot use window functions in WHERE, GROUP BY, or HAVING.

HAVING vs. WHERE in SQL: What You Should Know

This article is about SQL’s WHERE and HAVING clauses. Both clauses are part of the foundations of the SQL SELECT command. They have similar uses, but there are also important differences that every person who uses SQL should know. Let’s see what’s behind the HAVING vs. WHERE debate. In this article, we’ll suppose we work for a government social agency supporting people or families whose income is below a certain threshold.

Tag: Window Functions

SQL LEAD Function

Get to know the SQL LEAD function, an important function to know for anyone working with SQL in data analysis. Learn through examples how to use this function in practice. The SQL LEAD function is a very important and useful SQL window function. SQL window functions are essential for doing efficient data analysis. They allow you to work with groups of rows and single rows at the same time. They make writing complex reports easier.

Free Course of the Month: PostgreSQL Window Functions

Are you looking for the best way to master SQL window functions? Throughout March 2024, you can access the interactive course Window Functions in PostgreSQL for free. Boost your skills at no cost. Hurry, time is running out! Need a free PostgreSQL course on window functions? You've come to the right place! If you are reading this article, you probably know PostgreSQL is one of the most popular databases in the world.

What Are SQL Window Functions?

Need to up your data analysis game? Learn these SQL window functions here and you’ll take your analysis skills to the next level. Practice exercises and detailed explanations included! When I first heard about SQL window functions, I thought it was some strange marriage between SQL and Windows. I was wrong. The SQL window functions have nothing to do with that famous operating system. They are SQL functions that do computations on the set of rows related to the current row.

BigQuery Window Functions Explained

Keeping up with data analysis trends gives your organization – and your CV – the cutting edge. In this article, we'll look at BigQuery window functions and how you can use them to gain deeper insights into your data. Google's BigQuery, launched in 2010, is gaining traction as a popular choice with organizations needing to analyze large quantities of information quickly and to compare their own data against statistical data in the public domain.

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.

11 SQL Window Functions Exercises with Solutions

In this article, we present 11 practice exercises involving SQL window functions, along with solutions and detailed explanations. SQL window functions are a powerful feature that lets us extract meaningful insights from our data easily, yet few SQL courses offer SQL window functions exercises. This makes practicing window functions quite difficult. In this article, we’ll give you 11 practice exercises that feature window functions. All exercises shown in this article come from our interactive courses Window Functions and Window Functions Practice Set.

Free Course of the Month – Window Functions Practice Set

Do you want to enhance your SQL skills and learn how to prepare complex SQL reports? Maybe you've learned SQL window functions but need a refresher. This month, our unique SQL course Window Functions Practice Set is completely free! You're probably wondering ‘What's the catch?’. Why do we give something for free to our users? Well... we want to support people like you who are constantly striving to be better.

An Overview of MySQL Window Functions

MySQL window functions are very helpful when you want to create meaningful reports with SQL. In this article, we’ll demonstrate the most common window functions in MySQL and explain how to use them. MySQL 8.0 introduced a new feature: window functions. These functions are very useful to data analysts and anyone who creates reports using MySQL. Using them, you can easily compute moving averages, cumulative sums, and other calculations over specified subsets of your data.

How to Use SUM() with OVER(PARTITION BY) in SQL

Discover real-world use cases of the SUM() function with OVER(PARTITION BY) clause. Learn the syntax and check out 5 different examples. We use SQL window functions to perform operations on groups of data. These operations include the mathematical functions SUM(), COUNT(), AVG(), and more. In this article, we will explain what SUM() with OVER(PARTITION BY) does in SQL. We’ll show you the most common use cases in real-world applications to determine the ratio of the individual row value to the total value, calculate running totals, and find a custom order total that includes discounts for certain products.

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!

What Are Window Functions in SQL?

In this article, we discuss what window functions are and how they help you do your job as a data analyst or specialist. No, window functions have nothing to do with the operating system. The window here refers to a set of rows over which the function aggregates data. To learn how window functions work, what functions there are, and how to apply them to real-world problems, it’s best to take the Window Functions course.

How to Use the SQL PARTITION BY With OVER

At the heart of every window function call is an OVER clause that defines how the windows of the records are built. Within the OVER clause, there may be an optional PARTITION BY subclause that defines the criteria for identifying which records to include in each window. Read on and take an important step in growing your SQL skills! What Is the PARTITION BY Clause in SQL? The SQL PARTITION BY expression is a subclause of the OVER clause, which is used in almost all invocations of window functions like AVG(), MAX(), and RANK().

SQL Course of the Month – Window Functions in PostgreSQL

This is what distinguishes ordinary SQL users from professionals – SQL window functions! Would you like to practice them in PostgreSQL, on one of the best interactive SQL courses in the world, and pay nothing for it? Throughout November, you have access to the Window Functions in PostgreSQL course for FREE. You read it right: you won't pay a penny! What's the catch? Why would someone give you a free course?

What Is a Rolling Average and How Do You Compute It in SQL?

In this article, we will show three different examples of using SQL to calculate rolling averages. Learn this and you will take an important step in your SQL growth! A rolling average is a metric that allows us to find trends that would otherwise be hard to detect. It is usually based on time series data. In SQL, we calculate rolling averages using window functions. First, let’s talk about what rolling averages are and why they’re useful.

What Is the OVER() Clause in SQL?

Window functions are one of SQL’s most powerful resources, but they are not frequently used by the average SQL developer. In this article, we will explain how you can define different kinds of window frames using the OVER clause. The OVER clause is essential to SQL window functions. Like aggregation functions, window functions perform calculations based on a set of records – e.g. finding the average salary across a group of employees.

Difference Between ROWS and RANGE in Window Functions

Are you familiar with ROWS and RANGE window functions but not sure how they are different? This article makes those differences clear. In using SQL window functions, you’ve probably come across ROWS and RANGE clauses. If you haven’t, they are both parts of the Window Functions course. If you have, it’s quite likely you have been left confused why there are two keywords for the same function. Well, they are not the same!

5 Practical Examples of Using ROWS BETWEEN in SQL

SQL window functions are tremendously useful for calculating complex aggregations like moving averages or running totals. The ROWS clause allows you to specify rows for your calculations, enabling even more sophisticated window frames. Here are five practical examples of leveraging the ROWS BETWEEN clause in SQL. Window functions (also called OVER functions) compute their result based on a sliding window frame (i.e. a set of rows). They are similar to aggregate functions in that you can calculate the average, total, or minimum/maximum value across a group of rows.

How to Find the Nth-Highest Salary by Department with SQL

Learn how to find the nth-highest salary in SQL, and you’ll learn how to get the nth value in any data. In this article, I’ll focus on one problem and give you several solutions to that problem. The problem is stated in the title already: find the nth-highest salary by department using SQL. This may sound too specific. But by learning how to solve this, you’ll be able to find the nth value in any data, not just salaries.

How to Define a Window Frame in SQL Window Functions

The window function is a super powerful resource of the SQL language. At the core of any window function, there is a set of records, called the window frame, defined using an OVER clause. Knowing what records are in the window frame, how they are ordered, and what their upper and lower bounds are, are critical in understanding how window functions work. In this article, we will analyze and explain with examples how you can define different types of window frames.

Top 10 SQL Window Functions Interview Questions

Many interesting job positions require SQL skills – and that includes window functions, which are not commonly taught in online courses. In this article, I will cover the top window function questions for every experience level. If you’re going for a job interview for an advanced SQL position or for intermediate to advanced data analyst positions, you’ll probably be asked about your knowledge of SQL window functions. Don’t panic! Although these functions aren’t commonly covered in online courses, we’ve got the answers right here.

RANGE Clause in Window Functions: 5 Practical Examples

What is a RANGE clause in SQL window functions? Five practical examples will show you how and when to use it. The RANGE clause is used quite rarely in SQL window functions. I don't know why; maybe people are not used to it. This is a shame, because it's far from a pointless clause; it can be very useful, and I'll show you that in five examples. To learn how window functions work, what functions there are, and how to apply them to real-world problems, it’s best to take the Window Functions course.

How to Compute Year-Over-Year Differences in SQL

How did your business do this year compared to last year? The year before? Find out how to use SQL to calculate year to year and month to month differences. Year-over-year (YOY) comparisons are a popular and effective way to evaluate the performance of several kinds of organizations. Year to year differences are easy to understand – e.g. it’s easy to understand that your revenue growth is 35% year to year.

8 Best SQL Window Function Articles

Do you need a starting point for learning SQL window functions? Not sure which articles provide a solid foundation? We dove into the internet rabbit hole and found the eight best articles dealing with window and analytic functions. There are plenty of articles dealing with SQL window functions. Type those words into Google and you’ll find a huge number of articles returned. Reading articles is a good start if you want to learn something about window or analytic functions in SQL – provided, of course, that the articles you choose are trustworthy and up to date.

What Is Advanced SQL?

Are you confused about advanced SQL skills? What are they? This article will explain what advanced SQL can mean, especially as we use it on LearnSQL.com. I’m sure you find the phrases ‘advanced SQL skills’ or ‘advanced SQL topics’ very often. You read one article about advanced SQL and you’re happy with how easy these advanced topics seem to be. Then you talk to someone and you see they consider everything you know as basic SQL knowledge.

How to Find the Next Non-NULL Value in SQL

You need to find the next non-NULL value in a time series, but you don’t know how. Can you even do that in SQL? Yes, you can! This article will show you what to do. If you work with SQL, you will sooner or later confront NULL values. Having NULLs in a database is almost unavoidable. However, sometimes you want to avoid them in your reports. This is quite often true when you’re analyzing time series data; NULL values mean there’s no data available.

What Is the RANK() Function in SQL, and How Do You Use It?

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.

Why Aren’t SQL Window Functions Allowed in GROUP BY?

It’s true – the SQL order of operations means window functions aren’t allowed in GROUP BY. But you can use them anyway with this special trick. SQL window functions are one of the language’s most powerful features. However, the syntax of window functions is not easy to master. It has lots of details that can cause beginners to stumble. One of the most common traps is trying to use window functions in GROUP BY.

Why Learn SQL Window Functions in 2021?

SQL window functions provide some extremely powerful and convenient features for data practitioners. This article explains why you should learn window functions and when you should use them. I’ll also provide some examples to help you visualize the concepts. Window functions are part of advanced modern SQL – knowledge of which will definitely enrich the repertoire of any SQL user. Window functions have a broad range of uses and can be applied to almost all facets of business.

SQL Window Functions for Managers: Who Gets a Raise?

Window functions are one of the most powerful features in modern SQL. In this article, you will learn why window functions are so great. I will list you the most useful window functions and briefly explain when and how you can use them. Simple SELECT statements, in combination with WHERE, GROUP BY, and HAVING, are sufficient for many analyses at work. I used standard SQL for many years before I realized there is something more.

Best Online Courses for SQL Window Functions

In this article, I will summarize the top online tutorials and courses available on SQL window functions for enthusiasts of data analysis, data science, and data engineering. The information is here to help you embrace the topic with ease and feel comfortable using window functions in SQL databases. SQL window functions can help you solve some of the most common analysis challenges in business: What are the N most popular products for each month of the year?

Aggregate Functions vs Window Functions: A Comparison

If you aren’t familiar with SQL’s window functions, you may wonder how they differ from aggregate functions. When should you use window functions? In this article, we’ll review window functions and aggregate functions, examine their similarities and differences, and see which one to choose depending on what you need to do. After you’ve tackled basic SQL, you’ll probably want to get into some of its more advanced functions. That’s great; these functions make reporting and analysis easier.

A Comprehensive Introduction to Window Functions in MySQL

Do a deep dive into the working principles, syntax, and applications of various MySQL window functions. There are many open source databases you could choose; MySQL is consistently one of the most popular. But until 2018, there was no provision for including window functions in MySQL. Fortunately, all that has changed – starting from MySQL 8.0, SQL window functions were now available to MySQL users. Please note that window functions are available only in MySQL 8.

Six Window Function Templates to Save in Your Code Editor

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.

What Is the MySQL OVER Clause?

If you want to learn window functions in MySQL, you need to understand the OVER clause. In this article, we use real-world examples to explain what the MySQL OVER clause is, how it works, and why it’s so awesome. In 2018, MySQL introduced a new feature: window functions, which are accessed via the OVER clause. Window functions are a super powerful resource available in almost all SQL databases. They perform a specific calculation (e.

Six Examples Using MySQL Window Functions

Window functions are an advanced SQL feature available in most popular databases. MySQL had not supported them for a long time, but that changed in Version 8.0. They are helpful not only for analysts and people who create reports, but also for other professionals who use databases to select data needed. In this article, we explain the syntax of some popular window functions with practical examples. What Is a Window Function?

What a Moving Average Is and How to Compute it in SQL

Want to dive deep into time series data and examine long-term trends? Want to know what a moving average is and how to compute it in SQL? Then this article is for you. I’ll explain a powerful feature in SQL called window functions and show how you can calculate moving averages using them. The best way to learn about SQL window functions is the interactive Window Functions course at LearnSQL.

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?

Who Should Learn SQL Window Functions?

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.

How to Analyze a Time Series in SQL

Values ordered by time are called a time series. In this article, I’ll show you the most frequent patterns and teach you how to write queries for time series in SQL with the help of window functions. Maybe you’ve had the opportunity to analyze some variables where each value was associated with a time value. Such data – where values are ordered by time – is called time series data.

The LAG Function and the LEAD Function in SQL

LAG() and LEAD() are positional functions. A positional function is a type of window function. If you are not familiar with when and how to use them, what the syntax of each function is, why you might want to use them, and what the differences are, read on! LAG() and LEAD() are positional functions. These are window functions and are very useful in creating reports, because they can refer to data from rows above or below the current row.

How to Calculate the Difference Between Two Rows in SQL

Calculating the difference between two rows in SQL can be a challenging task. It is possible – and there’s more than one way to do it. In this article, I’ll explain how to use the SQL window functions LEAD() and LAG() to find the difference between two rows in the same table. The best way to learn window functions is our interactive Window Functions course. It contains over 200 hands-on exercise that will teach you all window functions concepts, from simple OVER() clause to complex topics such as combining window functions and GROUP BY clause.

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.

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.

How to Number Rows in an SQL Result Set

Have you ever needed to add a sequential number to the records in the result of an SQL query? It’s not as simple as it looks! Find out how to do it correctly in this article. To number rows in a result set, you have to use an SQL window function called ROW_NUMBER(). This function assigns a sequential integer number to each result row. However, it can also be used to number records in different ways, such as by subsets.

Why Should I Learn SQL Window Functions?

SQL has been around for more than 25 years. Its basic syntax – like SELECT, WHERE, GROUP BY, HAVING, and ORDER BY – is well known. But is there something besides traditional SQL? Can you go beyond the basics and improve your skills? The answer to this question is yes. There is a modern version of SQL. In this article, we are going to dive into the modern version and learn about SQL window functions.

SQL Course of the Month – Window Functions

Spring has come. It is nicer outside. It's a great time to learn something new. Which course should you choose? In April, it's worth it to bet on SQL window functions. What are they, what are they used for, and why are they worth knowing? I asked Agnieszka Kozubek-Krycuń, Chief Content Officer at Vertabelo, these questions. She has a PhD in mathematics and over 10 years’ experience teaching mathematics and computer science at the University of Warsaw.

SQL Window Functions Cheat Sheet

Unlock the full potential of SQL with our comprehensive Window Functions Cheat Sheet! This indispensable guide is designed to elevate your analytics capabilities and make complex data manipulations effortlessly accessible. Welcome to the ultimate resource for mastering SQL window functions - the SQL Window Functions Cheat Sheet! This invaluable resource provides you with the essential syntax, a comprehensive list of window functions, and real-life examples to enhance your SQL skills and analytics capabilities.

What Is a SQL Running Total and How Do You Compute It?

The SQL running total is a very common pattern, used frequently in finance and in trend analysis. In this article, you’ll learn what a running total is and how to write a SQL query to compute it. The best way to learn SQL is through practice. LearnSQL.com offers over 30 interactive SQL courses at various level of difficulty. Each course is interactive: there is a little bit of reading, followed by an exercise to practice what you've just read.

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.

Analyze Time Series COVID-19 Data with Window Functions

The COVID-19 pandemic really changed the way we live. No matter where you are, you're being impacted by this unpredictable virus. We do not know what the future holds, but we do believe in science and in better days to come. One thing that makes me as a data analyst particularly happy is that we have publicly available data. We can analyze that data and learn something from it. If you want to explore COVID-19 with the help of modern SQL constructions, keep reading — this article is intended for you.

SQL Window Functions vs. GROUP BY: What’s the Difference?

A very common misconception among SQL users is that there is not much difference between SQL window functions and aggregate functions or the GROUP BY clause. However, the differences are very significant. Perhaps the only similar point between GROUP BY and window functions is that both allow you to execute a function (such as AVG, MAX, MIN, or COUNT) on a group of records. I’d say that window functions’ special power is that they allow us to obtain results that otherwise would be almost impossible to achieve.

Why Window Functions Are Not Allowed in WHERE Clauses

Window functions are extremely powerful, but there are a lot of nuances and little details you need to learn about using window functions in order to use them correctly and efficiently. A fairly common question SQL users have is why window functions are not allowed in WHERE. TL;DR: You can use window functions in SELECT and ORDER BY. You cannot use window functions in WHERE, GROUP BY, or HAVING.

SQL Window Functions By Explanation

In our previous post, we explained how SQL window functions work by example. We started with some very simple, basic functions. Let's extend it by explaining subclauses in window functions. SQL window functions are a great way to compute results from a set of rows rather than a single row. As you know from our first article, the "window" in window function refers to the set of rows. We showed you some examples of simple window functions like RANK and LEAD.

Common SQL Window Functions: Positional Functions

Positional SQL window functions deal with data's location in the set. In this post, we explain LEAD, LAG, and other positional functions. SQL window functions allow us to aggregate data while still using individual row values. We've already dealt with ranking functions and the use of partitions. In this post, we'll examine positional window functions, which are extremely helpful in reporting and summarizing data. Specifically, we'll look at LAG, LEAD, FIRST_VALUE and LAST_VALUE.

SQL Window Function Example With Explanations

Interested in how window functions work? Scroll down to see our SQL window function example with definitive explanations! SQL window functions are a bit different; they compute their result based on a set of rowsrather than on a single row. In fact, the “window” in “window function” refers to that set of rows. Window functions are similar to aggregate functions, but there is one important difference. When we use aggregate functions with the GROUP BY clause, we “lose” the individual rows.

How to Use Rank Functions in SQL

Want to learn how to use ranking functions in SQL? They are a good choice if you want to start using SQL window functions! Learning about SQL window functions usually comes after you’ve built a foundation in the language, but these powerful functions take your skills up a level. As you master them, you’ll find better ways to solve query problems. When used for business intelligence applications, SQL queries combine data retrieval and advanced computations.

Window Functions: Part Two: Aggregating Data

In part one of this series on SQL Server window functions, the functionality of the OVER() clause was discussed. This article will focus on aggregate functions. The majority of these can be used in conjunction with OVER. Some, like SUM() and AVG(), are widely used. Others — including VARP() and CHECKSUM_AGG() — are not as well-known, but are potentially quite useful. OVER defines the user-specified range on which a function is applied.

Window Functions in SQL Server: Part One: The OVER() Clause

Window functions were first introduced in standard SQL 2003 and then extended in SQL 2008. Since SQL Server 2005, Microsoft has been steadily improving window functions in the database engine. These functions perform an aggregate operation against a user-defined range of rows (the window) and return a detail-level value for each row. Well-known aggregate functions include SUM, AVG, MIN, MAX, and many others. Recent versions of SQL Server have introduced ranking and analytic functions such as LAG, LEAD, RANK, CUME_DIST, and many others.

Tag: With

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.

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).

How the WITH Clause Works in SQL

Do you want to master complex SQL queries? Learn how to use the powerful WITH clause! In SQL, there are simple queries and complex queries. A simple query can take data from a table, apply a filter, and return the data as it is in the source table. A complex query may require complex transformations to the source data or may need to read and join data from multiple tables or views.

What Is the WITH Clause in SQL?

In this article, you will learn about the SQL WITH clause, also known as common table expression (CTE). We will go over some examples to demonstrate some of their use cases in light of their benefits. Introduction to the SQL WITH Clause The WITH clause in SQL was introduced in standard SQL to simplify complex long queries, especially those with JOINs and subqueries. Often interchangeably called CTE or subquery refactoring, a WITH clause defines a temporary data set whose output is available to be referenced in subsequent queries.

How to Draw a Christmas Tree in SQL

You can use SQL to manipulate all kinds of data, from huge analytical queries to brief single-purpose statements. But you can also use SQL just for fun, without any business requirements stifling your creativity. So, get out your jolly hat and prepare to sing O Christmas Tree as we create some quirky art with plain old SQL. Today, we’re going to generate some holiday-themed ASCII art, just for fun. That’s right.

Simplify SQL Code: Recursive Queries in DBMS

Hey SQL users! Are you repeating the same query in every report? Are your queries getting too complicated? Use recursive queries to simplify SQL code! Too many SQL reports can lead to clutter on your desktop and in your head. And is it really necessary to code each of them separately? Ad-hoc queries can share much of the same SQL code with managerial reports and even regulatory reports. Suppose you’ve been writing basic SQL code for a while.

How to Organize SQL Queries with CTEs

Common table expressions (CTEs) allow you to structure and organize SQL queries. Knowing how to organize SQL queries is a necessity when you begin to move deeper into SQL, so if you want to become an SQL master, you need to know CTEs. The SQL CTE has been part of standard SQL for some time now. CTEs – which are also called WITH statements – are available in all major RDBMS.

How Recursive Common Table Expressions Work

Recursive Common Table Expressions are immensely useful when you're querying hierarchical data. Let's explore what makes them work. Common Table Expressions (CTEs) are some of the most useful constructions in SQL. Their main purpose is improving query design, which makes queries easier to read. One of the reasons CTEs are so popular is that they let you divide longer queries into shorter subqueries. These are easier to read and edit.

Tag: With Clause

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.

Tag: Youtube

The Best YouTube Channels for Learning SQL

Updated on: April 21, 2024 Discovering the best YouTube channel from which to learn SQL is essential for beginners and enthusiasts alike, as SQL learning doesn't have to be challenging. If you're wondering whether watching online videos is the most effective way to master SQL, it's crucial to explore and identify high-quality YouTube channels dedicated to teaching SQL. This approach ensures you gain a comprehensive understanding of SQL through engaging and informative content.

Lesser-Known SQL YouTube Channels You Need to Follow Now!

Are you learning SQL? Many beginners start with YouTube tutorials. However, popular SQL clips are not always very helpful. You need to know which ones to watch so that you don't waste your time. In this article, I discuss SQL YouTube channels that, while not the most popular, deserve your attention. Click "subscribe" and watch! Those who follow my articles on LearnSQL.com know I'm not a huge fan of learning SQL from YouTube.