SQL Window Functions Series: LAG() and LEAD()
Dive deep into the powerful SQL window functions, LAG() and LEAD(). Explore their intricacies, discover real-world examples, and avoid common pitfalls.
2023-12-11
12,363 reads
Dive deep into the powerful SQL window functions, LAG() and LEAD(). Explore their intricacies, discover real-world examples, and avoid common pitfalls.
2023-12-11
12,363 reads
This article describes six performance metrics that ought to be central to your PostgreSQL monitoring strategy. By using a tool like SQL Monitor to track these metrics over time, and establish baselines for them, you'll be able to spot resource pressure or performance issues immediately, quickly diagnose the cause, and prevent them becoming problems that affect users.
2023-07-17
PostgreSQL monitoring is now supported by Redgate SQL Monitor to improve performance and reduce downtime.
2023-05-26
Haven't seen SQL Monitor in a while? If you'd like to see how it enables you to always have the answers to the health of your estate, and proactively find potential problems before they impact your users, here's a 30 minute demo for you to watch whenever it suits you.
2022-06-29
A third-party database monitoring tool is an investment that drives enormous value for the bottom line of your business in ten key ways. Here's how a tool like Redgate SQL Monitor can save you money, time and assist with security and compliance concerns.
2022-06-20
SQL Monitor works with your SQL Server data, wherever that data exists, from local instances to AWS RDS and AWS virtual machines. You can keep an eye on your estate, regardless of where the data is.
2022-06-17
With our four dedicated development teams, weekly updates and a commitment to listening to your feedback, SQL Monitor keeps getting better and better! If you haven't looked at it for a while, you might just be pleasantly surprised with how far it has come and how it can help your team work smarter. Take a look at the key features - and benefits - we've added since 2018 in this interactive infographic.
2022-03-04
In case you missed it: IDC’s recent Global DataSphere Forecast, 2021-2025, predicts that global data creation and replication will experience a compound annual growth rate (CAGR) of 23% over the forecast period. But what’s causing the growth? Where will all of that extra data be stored? And how should we, as data professionals, prepare for it?
2022-02-18
In a total 180° turn, find out which Redgate product Grant Fritchey wanted to get rid of a few years ago, why he changed his mind and why it's now one of the reasons he is so proud to work at Redgate!
2022-02-16
With 92% of organizations now reported to be multi-cloud, a well thought-out approach to cloud migration is imperative. Download our final insights report in this series on database monitoring to find out how 2500+ of your peers are dealing with the challenge.
2021-12-20
By Brian Kelley
I once kept a gratitude journal and I still have a task on my...
By Arun Sirpal
The goal is simple: register AgentDBA as an MCP server in Claude Code, so...
By Steve Jones
I was excited to try out the latest release of SSMS, v22.12.1 for this...
Hub/Cs 08218200233 Jl. Kyai Tamin No.110, Sukoharjo, Kec. Klojen, Kota Malang, Jawa Timur 65118
Telp/CS 08218200203 Jl. Kawi No.36, Gading Kasri, Kec. Klojen, Kota Malang, Jawa Timur 65116
Hi everyone, We previously used the Microsoft Access Database Engine 2016 (ACE) provider. As...
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