Ryan Adams

Ryan Adams is a Senior Premier Field Engineer for Microsoft. He works directly with customers to help them realize their business potential and accelerate their digital transformation on premises and in the cloud.

Previously, Ryan was a Microsoft Data Platform MVP and spent 19 years working for a fortune 100 company. His passion is the SQL Server Engine, High Availability, and Disaster Recovery. He also served on the Board of Directors for the North Texas SQL Server User Group, was President of the PASS Performance Virtual Chapter, was a PASS Regional Mentor, and served as a Director for the PASS organization.

Blog Post

Build a SQL Cluster Lab Part 3

You are going to create a multi-subnet Availability Group in Part 3 of our series on how to build a SQL Cluster Lab. First you give the Cluster Name...

2019-11-18 (first published: )

563 reads

Blog Post

Build a SQL Cluster Lab Part 1

This article is Part 1 in a series of articles showing how to build a SQL Cluster Lab. It covers building a Windows Cluster in Hyper-V that supports both...

2019-11-06 (first published: )

653 reads

Blogs

AI Innovation in Microsoft Keynote

By

I’m thrilled to be covering the Microsoft Keynote: Fuel AI Innovation with Azure Databases on Day...

Benefits of Migrating from Azure Synapse Analytics to Microsoft Fabric

By

Many customers ask me about the advantages of moving from Azure Synapse Analytics to...

PASS Summit 2024 – A Very Different World

By

The last data centric conference I attended was the PASS Summit in 2019. A...

Read the latest Blogs

Forums

What's New for the Microsoft Data Platform

By Steve Jones - SSC Editor

Comments posted to this topic are about the item What's New for the Microsoft...

Using Outer Joins

By Steve Jones - SSC Editor

Comments posted to this topic are about the item Using Outer Joins

Closest to ProcDate

By boehnc

Not sure I have this 2nd left join correct. I need to grab the...

Visit the forum

Question of the Day

Using Outer Joins

I have this data in a SQL Server 2019 database:

Customer table
CustomerID CustomerName
1          Steve
2          Andy
3          Brian
4          Allen
5          Devin
6          Sally

OrderHeader table
OrderID CustomerID OrderDate
1       1          2024-02-01
2       1          2024-03-01
3       3          2024-04-01
4       4          2024-05-01
6       4          2024-05-01
7       3          2024-06-07
8       2          2024-04-07
I want a list of all customers and their order counts for a period of time, including zero orders. If I run this query, how many rows are returned?
SELECT 
  c.CustomerName, COUNT(oh.OrderID)
 FROM dbo.Customer AS c
LEFT JOIN dbo.OrderHeader AS oh ON oh.CustomerID = c.CustomerID
WHERE oh.Orderdate > '2024/04/01'
GROUP BY c.CustomerName

See possible answers