Repair SQL Server on Linux after an Ubuntu distribution upgrade
SQL Server 2017 is supported on Ubuntu 16.04 LTS (Long-Term Support), however that version of Ubuntu Linux is now more...
2018-07-25
361 reads
SQL Server 2017 is supported on Ubuntu 16.04 LTS (Long-Term Support), however that version of Ubuntu Linux is now more...
2018-07-25
361 reads
I was lamenting to my friend and fellow MVP Shamir Charania (blog | Twitter) that I didn’t have a topic for...
2018-08-01 (first published: 2018-07-18)
2,988 reads
Relational database management systems (RDBMS) like SQL Server and Azure SQL Database are very good at managing normalized data. Efficient...
2018-07-11
335 reads
On the first day of January 2017, I was honoured to receive an email naming me as a Microsoft MVP...
2018-07-04
321 reads
Folks, we all like to make sure we’re doing our level best to make things work smoothly. So why am...
2018-06-27
379 reads
Last time we looked at DATEPART(). This post is all about the DATENAME() function. So many similarities There are many...
2018-06-20
946 reads
In my previous posts in this series we’ve seen reference to Transact-SQL (T-SQL) functions that are used to get the...
2018-06-13
306 reads
I was minding my own business innocently reading a blog post by Erik Darling, when this tip smacked me in...
2018-06-06
1,160 reads
Recently I wrote a post about date and time functions you should never use, which contained an opinion I’ve expressed...
2018-05-30
470 reads
Last week I had the privilege of reviewing possibly the best SQL Server production environment I’ve seen in Canada. During...
2018-05-23
491 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