How To Use SQL Archives

This archive contains slew of posts on how to use SQL to solve problem.  If you have a question about a particular issue, or technique, you may find a solution here.

For instance, here is one of our more “fun” article on how to use SQL to create a bar chart:  How to Create A Bar Chart Using SQL Server

If you’re studying for the 70-761 Querying Microsoft SQL Server certification, these two articles are a must read:

All the examples for this lesson are based on Microsoft SQL Server Management Studio and the sample databases AdventureWorks and WideWorldImporters.  You can get started using these free tools using my guide Getting Started Using SQL Server

2

5 Typical SQL Syntax Mistakes

For a beginner, learning any kind of programming language can be challenging and can cause you to make mistakes quite often. However, this is how we learn. Learning SQL syntax programming involves the same concept. After a while, you will start to see common patterns in those mistakes, and you will learn more as we […]

Continue reading
7

Write Better SQL – Step 3 of 3

To write sql, we’ll take all the information we’ve compiled in the previous articles and map it to the appropriate SELECT clause.  The series starts with this introductory article. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.  You can get started using these free tools […]

Continue reading

How to Write SQL – Understand Database Table Meanings and Relationships – Step 1

The first step to write SQL is to understand the database tables meanings and relationships.  This is important, as complex queries often span more than one table.  Knowing the purpose of the table and how they relate to one another is key.   The series starts with this introductory article. All the examples for this […]

Continue reading
18

How do I combine results from several SQL tables (hint: there are three ways)

Combine data in SQL

Many times in a relational database the information you want to show in your query is in more than one table.  This begs the question “How do you combine results from more than one table?” All the examples for this lesson are based on Microsoft SQL Server Management Studio and the AdventureWorks2012 database.  You can […]

Continue reading
13

Use SQL Server to Sort Alphanumeric Values

Sort Alphanumeric Values with SQL Server Recently a reader asked me how to sort an alpha numeric field in SQL in natural order.  Alphanumeric values are commonly found and don’t sort naturally using numeric methods. When we have a numeric fields we expect values to be sorted in ordinal order, for example: 1,2,5,7,10,11,15,20,21 However when […]

Continue reading
>