Book Review: SQL Server 2017 on Linux
I don’t have any statistics but I think most IT Professionals in the SQL Server field are managing or developing...
2019-01-11
486 reads
I don’t have any statistics but I think most IT Professionals in the SQL Server field are managing or developing...
2019-01-11
486 reads
2018 has come and gone. And we’re on a new year once again. This is another opportunity for a new...
2019-01-04
268 reads
More and more tools are becoming available for data analysts and data scientists. These tools provide convenience and lower the bar...
2019-01-03 (first published: 2018-12-22)
2,465 reads
It has been a busy year so far. Last March, I did a review, as a Technical Reviewer, for a...
2018-11-02
313 reads
SQL Server 2017 In-Database Machine learning has brought the analytics closer to the data. It is now convenient to do...
2018-04-11
979 reads
Creating a bar graph with R in SQL Server 2017 is relatively easy. It’s just a matter of finding the correct...
2018-04-05 (first published: 2018-04-03)
2,572 reads
As a SQL Server pro, I spend most of my productive time in the SQL Server Management Studio (SSMS). I...
2018-04-04 (first published: 2018-03-27)
2,978 reads
Prior to SQL Server 2016, running R on Microsoft platform required an installation of the R Language and its environment...
2018-03-22 (first published: 2018-03-13)
4,340 reads
Installing R packages in SQL Server 2017 is a breeze with the stored procedure sp_execute_external_script. But so far, it is limited...
2018-03-20
473 reads
Disclaimer: I’m one of the Technical Reviewers for this book.
With the rising demand for cloud computing and wide adaptation of...
2018-03-19 (first published: 2018-03-06)
2,723 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