SQLMentor: Do you have a mentor?
I’ve been looking for better ways of learning and improving my SQL Server skills. Blogs, BOL, webcasts, and training videos...
2013-04-13
742 reads
I’ve been looking for better ways of learning and improving my SQL Server skills. Blogs, BOL, webcasts, and training videos...
2013-04-13
742 reads
There is something about the Silicon Valley that attracts the innovative and creative individuals. The “misfits, rebels, troublemakers, and the...
2013-02-20
934 reads
Update:
This book project got its second life. I am now collaborating with another author to bring this book to completion....
2013-02-16
949 reads
I’m in the middle of writing the first chapter of my book. I’m not just ready to announce the working...
2012-12-05
858 reads
Every time you run the SkyDrive Client on your device, a laptop in my case, all your files from the cloud are downloaded to...
2012-11-26
984 reads
There are things that I’m thankful for this year. Yes, I also got a lot of setbacks but that wouldn’t...
2012-11-22
708 reads
I needed to upgrade my tools. It was not a matter of “want” but of “need”. It’s no longer enough to have just the bare...
2012-11-19
975 reads
Developers will love this latest improvement, specially those that have SQL Server Express installed on their laptops or workstations but...
2012-11-15
1,305 reads
You probably heard about 7 Days To OLAP by Simon Doubt. It’s Simon’s experiment on learning OLAP during his stay...
2012-11-10
1,611 reads
Weeks Before The Event
Check for conflict in Schedule
Family Activities (Y/N)Business Appointment (Y/N)Other Commitments (Y/N)Plan the Trip
Distance (calculate travel time)Budget $ (Gasoline,...
2012-09-15
720 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...
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
Comments posted to this topic are about the item Nobody Forgot Math With Calculators
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