Articles Cookbook

Tag: Sql Basics

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. In the previous article, we talked about how you can use the SQL Server DATEPART() function with week or iso_week to group events by week. The query might look like this: SELECT DATEPART(week, RegistrationDate) AS Week, COUNT(CustomerID) AS Registrations FROM Customers WHERE '20180101' The result looks something like this: WeekRegistrations 1 58 2 123 .

Online Education in the Times of COVID-19

LearnSQL.com grants free access to their Interactive courses till 04/20/2020. People around the world are faced with a new challenge. A challenge which requires swift action and adaptability. Students and teachers, employers and employees, families and friends. Many have shown vigilance and decisiveness, while at the same time trying their best to maintain their everyday-life continuity. However, there are those who, due to the current circumstances, need to postpone plans and invest their resources in different areas.

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.

19 Top SQL Articles for Beginners Published in 2019

In 2019, a lot of new SQL articles were written for beginners. This kind of resource is useful not only for professionals. SQL articles allow you to develop skills, expand your knowledge, and use SQL in practice. They are a very good way to learn SQL. In this post, I gathered 19 top SQL articles of 2019. Let’s also learn SQL from articles! List of Top SQL Articles Published in 2019 We will start with five of the best articles published on the LearnSQL.

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.

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.

A Non-Technical Introduction to Learning 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. How to Install Microsoft SQL Server 2017 In this guide, I’ll show you the SQL Server 2017 installation step by step.

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.

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.

Key Insights for Mastering SQL Queries Using Tinder Data Example

Going from zero to one can be daunting in any endeavor. The same is true for learning new programming languages, even simple ones like SQL. In this article, we’ll take a look at some key insights that will help you understand the nuances of mastering SQL queries. If you’ve never used SQL, you’re in the right place. When learning anything new, you’ll find that there are always some key insights or tips that can help you on your way.

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

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. Imagine you’re attending a meeting with the development staff and suddenly feel as if you’re listening to white noise.

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 – Solve Basic SQL Questions with the 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.

Here’s Why You Should Learn SQL

Why learn SQL? We asked our users about it. This is what we’ve learned. At LearnSQL.com, we help people with no computer science background to understand the core concepts of databases and data science. For example, we teach users how to extract the most important data from a database to build simple reports and how to understand key statistical metrics in data analysis. We love to provide easy-to-understand examples that thoroughly depict complex technical concepts.

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.

15 Best SQL Articles for Beginners Published in 2017

For this post, I've gathered 15 of the most interesting SQL articles published in 2017. If you're looking for articles on SQL for beginners, want to learn more about databases and SQL queries, or just expand your knowledge of SQL, this article is perfect for you. Let's dive right in! Top 3 Vertabelo Academy Articles I'll start off the list with three of the most popular Vertabelo Academy SQL articles.

18 Useful Important SQL Functions to Learn ASAP

Beginning with SQL: Useful Functions to Master 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. There are many useful SQL functions for working with different data types. Once you practice with some of the most common ones, you'll gain enough confidence to move on to more advanced material.

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.

Digging Into Data: Explore and Analyze Survey Results With 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.

How Often Employees Are Running Late for Work: SQL Datetime and Interval SQL Arithmetic

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.

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.

What Is Vertabelo’s SQL Cheat Sheet?

Everyone, from rookie programmers to SQL ninjas, needs a bit of help now and again. Enter Vertabelo's SQL Cheat Sheet! Working with databases is hard. There's a lot of data to manage, which can be daunting. But the main challenge many database users face is the SQL commands themselves. It's all right when you're using the same familiar ones day after day, but what about the commands you dust off once or twice a year?

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.

SQL Mythbuster – 5 Reasons Why No One Should Be Afraid of SQL

Anyone can learn SQL. It’s not as hard as you think! 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. Let me tell you my own story. A few years ago, I wasn’t considering learning SQL or anything else that I labelled “technical”. My background is in sociology, journalism, and scriptwriting, and I thought computer languages were pretty sci-fi.

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? INNER JOIN combines data from multiple tables by joining them based on a matching record.

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.

A Beginner’s Guide to SQL Aggregate Functions

Aggregate functions are powerful SQL tools that compute numerical calculations on data, allowing the query to return summarized information about a given column or result set. These functions can be used in conjunction with the GROUP BY statement. Let’s see how they work using some easy examples. SQL Aggregate Functions Suppose we have users residing in a city, and we store their information in two tables. These tables and their relationship are shown below:

Introducing SQL Set Operators: Union, Union All, Minus, and 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.

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.

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

Which books will help you build your database skills? We look at five awesome SQL books. There’s a common saying that “all wise men read books”. I would say that all professionals read books – particularly those related to their field. There are many books about databases and SQL; most are tied to specific vendors (DB2, Oracle, MS SQL) but there are also plenty that are vendor-neutral. In this article, I’m going to review a few books that I would recommend to SQL learners at various levels of proficiency.

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?