On bias
Last week saw the second month of my employment at Microsoft. I admit that I’m enjoying my job, and I can’t deny that the reduced amount of time I’ve...
2022-03-30
45 reads
Last week saw the second month of my employment at Microsoft. I admit that I’m enjoying my job, and I can’t deny that the reduced amount of time I’ve...
2022-03-30
45 reads
I am thrilled to announce that Microsoft Press (Pearson) has agreed to let us do another Inside Out book this year. This news is so fresh I haven’t even...
2022-03-23
36 reads
I wrote a post a couple weeks ago about not changing port 1433 for security reasons. I received this comment, which is not visible on that page because it...
2022-03-16
205 reads
At my new day job, one of the things we want to do is migrate a portion of a really large Git repository (over 20GB) which I’ll call LargeRepo,...
2022-03-09
67 reads
Since we’re on a recent theme of revising long-held best practices that are not, here’s a timely one for you: Don’t change your default SQL Server port for security...
2022-03-02
259 reads
A short post this week. While I was helping some friends recently, we experienced a curious thing where as soon as an application was started up, it was immediately...
2022-02-23
51 reads
Last year I wrote a series of posts about accessibility as it relates to presentations, and one aspect which I didn’t cover is within the documents themselves. We create...
2022-02-16
120 reads
On Wednesday February 23rd, 2022, the Calgary Data User Group will be hosting our first user group session of the year, featuring Warwick Rudd. The topic is an introduction...
2022-02-09
37 reads
(This post was co-authored by Erik Darling.) The more things stay the same, the more they change… No, that’s not a mistake. In fact, it’s a reference to long-held...
2022-02-02
80 reads
I have been selected to speak at the DataGrillen conference later this year. I will be presenting my session How Does SQL Server Store That Data Type?, which I debuted during...
2022-01-26
37 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