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.
Want to learn how to use SQL window functions? Ranking functions are a good place to start! 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. These operations are more complex than those used in OLTP systems.
Here’s a shock: not everything in the movies is true. But these five documentaries offer interesting insights into the Internet and its people. Non-tech people tend to consider coding, hacking, and anything remotely dev-y as mysterious and magical processes. This myth is helped along by the movie industry, and there’s nothing wrong with that. Movie watchers generally like thrilling, action-packed stories, and coding can be anything but exciting. But not every good movie needs to be filled with action; some get our brains going by presenting new ideas or interesting viewpoints.
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. 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.
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 Vertabelo Academy post Learning SQL JOINs Using Real Life Situations, you know that there are many types of JOINs.
-- -- Previously, we've discussed the use of SQL aggregate functions with the GROUP BY statement. Regular readers of the Vertabelo Academy 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.
Learning from books is so 1999. Can app-based learning do any better? Do you like wasting your time? I don’t. Any time I start something, I find out how to do it efficiently. For me, this means learning new skills using apps and online learning rather than books. Online and app-based learning focuses on you, the student. This is the exact opposite of traditional learning, which is teacher-driven. There is a physical classroom and students, but the teacher plays the primary role.
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:
-- -- When you need to combine information from multiple tables or queries, SQL set operators are a useful tool. 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. Let’s say we want to present every aspect of some key data group in one results table (e.
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.
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. Pivoting 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.
The JOIN statement lets you work with data stored in multiple tables. This article is a practical introduction to the SQL JOIN. 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. This article will give you examples that illustrate how we use JOINs, how each type of JOIN works, and when to use each type.
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. Previously, we looked at the SQL pattern of matching NULLs. This is important when you are comparing columns containing NULL values. Today, we’re going to consider another SQL practice: conditional summarization with CASE operator.
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” demonstrated how to use CASE in an ORDER BY clause.
Think that FROM only specifies tables in an SQL statement? Think again … When I first began to work with SQL, I saw the FROM clause as the simplest part of any query. You’d put only one table there, or may be two or more tables in the case of a join. That was all I thought about the FROM clause in those days. As I began to learn more about SQL, I discovered that there are a lot of techniques that can be used in a FROM.
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.
What happens when a database receives commands from two different users? We look at the problems that can arise and how to avoid them. Every time you execute a statement in your database, you change the database’s state. When working in a multi-user environment with asynchronous database access, it will sometimes happen that two users are trying to change the same record at the same time. If both of their statements is an operation that changes the database’s state, this can create erroneous results.
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.
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.
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. In statistics, certain measurements are known as moments. You can describe continuous variables (i.e. a variable that has a large range of possible numbers, such as household incomes in a country) with population moments.
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.
“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.
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. In SQL, NULL is a special marker used to indicate that a data value does not exist in the database. For more details, check out Wikipedia’s explanation of NULL in SQL.
Recipes that make querying easy, even for the novice. In today’s information age, we have at our fingertips almost an overabundance of teaching and information on any and every subject. In the midst of this glut of information, it can be hard to decide which is the best source for our needs. But, fear not; we are here to assist you as you navigate through decisions about books on SQL topics!
Matching patterns is a very important and useful ability. In this article, we look at how you can match patterns using the SQL LIKE operator. Pattern matching is a very simple concept. It allows you to search strings and substrings and find certain characters or groups of characters. You can find pattern matching mechanisms in SQL and in other programming languages. In this article, we’ll examine how the LIKE operator can be used to search substrings.
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 Vertabelo Academy, you will start to understand SQL’s different data types. In this article, we will cover the numeric data types of ANSI SQL. 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.
-- -- SQL 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. 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.
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 issues you’ll face and will help you tackle them successfully. One of the best ways to prevent SQL errors is to keep your queries clear and readable. It’s very easy to forget the ideas behind your code! If you have to revisit it (and you will), messy code can be hard to understand.
Internet-based learning is very popular. Knowing your learning style and motivations will help you study smarter, not harder. We tend to spend a lot of time online these days. Between watching funny YouTube videos, catching up on news and celebrity gossip, and binge-watching our favorite Netflix series, we even find the time to learn new skills. But are we in a constant learning process? How can we pluck out – from the vast resources of the Internet – the exact courses and methods that will work for us (or you) personally?
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.
Long SQL queries are notoriously hard for beginners to structure and understand. These five tips will teach you the best practices for writing and formatting complex SQL code. 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.
Database and Business Intelligence (BI) developers create huge numbers of reports on a daily basis. Many of these reports include statistical analyses. How can you perform statistical queries in SQL? Statistics are very useful as an initial stage of a more in-depth analysis, i.e. for data overview and data quality assessment. However, there are not many statistical functions in SQL Server. In addition, a good understanding of statistics is not very common among T-SQL practitioners.
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.
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?
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… In this article, we help you prepare for the SQL and database aspects of a job interview. In a previous article, I explained how can you boost your career by learning SQL. It opens up opportunities in and out of IT, as this query language is used practically everywhere.
There are two major camps in the relational database development world: OLTP and OLAP. In this post, we consider the differences and similarities of these two systems. First of all, both OLTP (on-line transactional processing) and OLAP (on-line analytical processing) are used in business applications, especially — although not exclusively — in data warehousing and analytics. Together, they form the two different sides of the analytics/warehousing coin: storing and manipulating the data on one hand and analyzing it on the other.
You’ve know about using SQL with databases. How does SQL fit in with app 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. Let’s say you’ve done that work already and you’re preparing to start the more detailed stuff.
Vertabelo Academy 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 quick explanation of all you need to get started with SQL. The Database You might have already heard that SQL is used with databases. What exactly is a database? In the most general sense, it is an organized collection of various kinds of data.
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?
Describing a “typical” day for an 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 an SQL developer might do. Morning: Arrive at Work The cornerstone of any software engineering endeavor is caffeine, and lots of it.
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.
GROUP BY is an important part of the SQL SELECT statement. But new SQL coders can run into some problems when this clause is used incorrectly. Here’s how to avoid those issues. You’re learning SQL. You know how to SELECT some data FROM a table and how to filter the data with a WHERE clause. You can process the data using aggregate functions (MIN, MAX, SUM, AVG, and others). But when you’re dealing with a lot of data, you may need to narrow it down even more.
The tech sector is experiencing strong job growth. Should SQL be on your list of must-have skills? If you’re even remotely interested in finding a new job, you’ve probably noticed that IT jobs are hot. Not only are a lot of these jobs available, they offer some pretty great opportunities to challenge yourself, grow, and build new skills. And the compensation tends to be pretty awesome too. In today’s world, technology is evolving at an almost daily pace, and this is producing a flood of data that has to be managed.
How can you store textual information in database tables? Read this post to discover your options. 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 Vertabelo SQL Academy. Most data types are classified as NUMERIC, CHARACTER, or DATE. In this post, we’re going to focus on TEXTUAL or CHARACTER data types. These data types handle groups of alphanumeric characters – i.
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.
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. Mastering SQL Queries Interactive SQL courses are one way to get immediate feedback on your queries. These courses, like the ones offered in Vertabelo Academy, usually introduce new concepts and then ask you to have a go at them right away.
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.
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, we have a lot of options! 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? This article tackles these questions and gives you a roadmap – or should we say a couple of them – of your journey towards SQL proficiency.
Correlated subqueries are the only way to solve some SQL statements. But they can be very slow. In this post, we’ll talk about why, how, and when to use them. 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.
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 post, we’ll discuss five common mistakes people make when writing SQL. Watch Your Language (and Syntax) The most common SQL error is a syntax error.