I have a table with a 'status' one is always 'In Delivery' and its followed up by another status such as 'Rejected' or 'Delivered'
I need to find the average time it takes for each 'In delivery' status to be updated as rejected or delivered by the LDPID
I wasn't sure if I should use rank or avg any ideas?
We have a table with the following schema -
CREATE TABLE [dbo].[Delivery](
[DeliveryId] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[LeadId] [bigint] NOT NULL,
[LDPId] [bigint] NOT NULL,
[DeliveryStatus] [nchar](25) NOT NULL,
[DeliveryDate] [datetime] NOT NULL
CONSTRAINT [PK_LeadDeliveryLog] PRIMARY KEY CLUSTERED
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70) ON [PRIMARY]
) ON [PRIMARY]
Here is an example of the data in the table -
deliveryid leadid lpdid deliverystatus deliverydat
View Complete Post