Is it possible to use Joins, Subqueries, and Unions in one Query?
A reader recently asked me to help them solve a problem combining data from multiple tables into a single result. What was interesting was that the solution used the three ways to combine data that we...
View ArticleSQL DISTINCT and TOP in Same Query
This article is inspired by a series of questions that one of my readers, Nan, recently sent me regarding DISTINCT, TOP, and ORDER BY. All the examples for this lesson are based on Microsoft SQL...
View ArticleForeign and Primary Key Differences (Visually Explained)
In this article we learn the difference between a primary key and a foreign key, and why both are important to maintaining a relational database structure. All the examples for this lesson are based on...
View ArticleUsing OFFSET and FETCH with the ORDER BY clause
In this article we explore the OFFSET and FETCH clauses. OFFSET and FETCH are used in conjunction with the SELECT statement ORDER BY clause to provide a means to retrieve a range of records. The...
View ArticleWhat is the Difference between TOP and OFFSET & Fetch?
Both TOP and OFFSET & FETCH can be used to limit the number of rows returned. OFFSET and FETCH can return similar results to top, but there are differences which may influence which method is best...
View ArticleSQL CASE Statement – Simple and Searched Forms
The main purpose of a SQL CASE expression returns a value based on one or more conditional tests. Use CASE expressions anywhere in a SQL statement an expression is allowed. Though a truly an...
View ArticleSeven SQL Server Data Types you Must Know
In SQL the columns of a table are defined to store a specific kind of value such as numbers, dates, or text; these are called data types. With over thirty types of SQL server data types to choose...
View ArticleHow can I find Duplicate Values in SQL Server?
In this article find out how to find duplicate values in a table or view using SQL. We’ll go step by step through the process. We’ll start with a simple problem, slowly build up the SQL, until we...
View ArticleConverting Between Data Types with SQL Server Functions
SQL server uses data types to store a specific kind of value such as numbers, dates, or text in table columns and to use in functions, such as mathematical expressions. One issue with data types is...
View ArticleBuilt-In Functions (SQL Server)
Built-In functions are used in SQL SELECT expressions to calculate values and manipulate data. These functions can be used anywhere expressions are allowed. Common uses of functions include to change...
View ArticleIntroduction to SQL Server’s Built-In Logical Functions
Logical functions provide a way to use logical conditions to display one of several values. You can use logical functions to test a field’s value such as gender (M or F) and display another...
View ArticleIntroduction to SQL Server’s Mathematical Functions
Math Rocks! SQLServer includes many mathematical functions you can use to perform business and engineering calculations. Many of these aren’t used in typical day-to-day operations; however, there are...
View ArticleSubqueries versus Joins
Joins and subqueries are both be used to query data from different tables and may even share the same query plan, but there are many differences between them. Knowing the differences and when to use...
View ArticleIntroduction to SQL Server’s Common String Functions
The built in SQL String functions make it possible for you to find and alter text values, such as VARCHAR and CHAR datatypes, in SQLServer. Using these functions you can alter a text value such as...
View ArticleLearn to use SQL Server Date Functions
SQL server’s date functions provide you a set of function that you can use to manipulate dates. The function are used for a wide variety of operation such as adding weeks to a date, calculating the...
View ArticleWhat Is the Difference Between a Join and a UNION?
Both Joins and UNIONS can be used to combine data from two or more tables. Read this article to find out each command’s strengths and when to use them. To get the most of this and our other lessons be...
View ArticleWhat is the Difference between Inner and Outer Joins?
Both inner and outer joins can be used to combine data from two or more tables; however, there are some key differences! Read this article to find out each command’s strengths and when to use them. To...
View ArticleKnow when to use Cast versus Convert
In this article we’re going to explore the CAST and CONVERT functions to understand whether there are any significant differences worth knowing when we want to convert data from one type to another....
View ArticleCommon Table Expressions (Introduction to CTE’s)
Common Table Expressions or CTE’s for short are used within SQL Server to simplify complex joins and subqueries, and to provide a means to query hierarchical data such as an organizational chart. In...
View ArticleNon Recursive CTEs Explained and Why to Use Them
Introduction to Non Recursive CTEs In this article we explore non recursive CTEs (Common Table Expressions). This is a broad class, and basically covers every form of CTEs except those that call...
View Article