Connect with your SQL Community on Slack
Slack is a popular tool for team interaction. To describe it quickly, it's a feature-rich persistent chat room, with threads,...
2025-09-25 (first published: 2017-05-04)
634 reads
Slack is a popular tool for team interaction. To describe it quickly, it's a feature-rich persistent chat room, with threads,...
2025-09-25 (first published: 2017-05-04)
634 reads
For a variety of reasons, including your Microsoft MVP activity reports, you might want to summarize your GitHub activity across multiple repos. For contributors to Microsoft open-source docs on GitHub,...
2025-06-20 (first published: 2025-06-05)
337 reads
I recently reviewed, worked on, and added a similar example to the DATETIMEOFFSET Microsoft Learn Docs article at the recommendation of my colleague Randolph West, who guessed (accurately) I...
2024-05-22 (first published: 2024-05-03)
446 reads
This technical blog is hardly the ideal, but I'll use this space here to summarize some of the guidance that my colleague Randolph West and I presented at a...
2023-11-13 (first published: 2023-10-27)
414 reads
Met an eager young volunteer at SQLSatBR over the weekend who inspired me to update a blog post that hadn't been refreshed in a few years. See the [UPDATED] Training...
2023-08-18 (first published: 2023-07-31)
638 reads
Looking forward to #jambalaya at #SQLSatBR on July 29! Register today: sqlsatbr.comI hope to see as many people as possible that weekend, I'll be there at the Friday night...
2023-07-22 (first published: 2023-07-21)
65 reads
SQL Server 2022 Administration Inside Out is now available for pre-order from Microsoft Press. This book is far more than a quick update. We've rewritten and refreshed large portions of...
2023-03-25 (first published: 2023-03-24)
158 reads
This blog post summarizes the type of technical questions I would ask candidates for a Microsoft SQL Server data platform administrator and database developer role.Hopefully this helps both candidates...
2023-03-08 (first published: 2023-02-28)
1,418 reads
Part 2 of 2. This blog post is co-authored by Ajayi Anwansedo, PhD and William Assaf, who met and worked together at The Futures Fund, a STEM non-profit which offers introductory coding and...
2023-02-03 (first published: 2023-01-23)
323 reads
Fresh off of a two-part, co-authored blog series on certification exams and test-taking prep, I've got a fresh batch of fun sample questions for the January 2023 Data Weekender Exam...
2023-01-24
49 reads
By Steve Jones
I’ve become an EV guy. I was talking with a friend who was selling...
In a previous post I talked about how we can use T-SQL Snapshot Backups...
By Steve Jones
A bit of a photo dump, but a few fun memories for me from...
Hello, We recently migrated a database from SQL Server 2014 to SQL Server 2022....
Comments posted to this topic are about the item Detecting Outliers in Power BI...
Comments posted to this topic are about the item Missing Returns
I have a few tables in my SQL 2025 database:
CREATE TABLE [dbo].[Customer] ( [CustomerID] [int] NOT NULL, [CustomerName] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [AddressKey] [int] NULL, [CustomerStatus] [int] NULL, [CustomerContact] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [ContactEmail] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [PreferredName] [char] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] GO ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [CustomerPK] PRIMARY KEY CLUSTERED ([CustomerID]) ON [PRIMARY] GO CREATE TABLE [dbo].[Orders] ( [OrderID] [int] NOT NULL, [CustomerID] [int] NOT NULL, [ProductID] [int] NOT NULL, [OrderDate] [date] NOT NULL, [Quantity] [int] NOT NULL ) ON [PRIMARY] GO ALTER TABLE [dbo].[Orders] ADD CONSTRAINT [PK__Orders__C3905BAFE0146D59] PRIMARY KEY CLUSTERED ([OrderID]) ON [PRIMARY] GO ALTER TABLE [dbo].[Orders] ADD CONSTRAINT [FK_Orders_Customers] FOREIGN KEY ([CustomerID]) REFERENCES [dbo].[Customers] ([CustomerID]) GO ALTER TABLE [dbo].[Orders] ADD CONSTRAINT [FK_Orders_Products] FOREIGN KEY ([ProductID]) REFERENCES [dbo].[Products] ([ProductID]) GO CREATE TABLE dbo.CustomerReturn ( EntryID INT NOT NULL CONSTRAINT CustomerReturnPK PRIMARY KEY , CustomerID INT , ReturnDate DATETIME , OrderID INT NOT NULL ) GOThere are multiple rows in all these tables. I am trying to find how many customers have never returned anything, and I run this:
SELECT count(*)
FROM dbo.Customer
WHERE CustomerID NOT IN
(
SELECT CustomerID FROM dbo.CustomerReturn
);
I get zero rows, but I know there are customers who have not returned anything. What is wrong? See possible answers