Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Get the time difference of 80% of total record

$
0
0
Table Name : message_queue_detailsField Name : ID, MobileNumber, SubmitDate, MsgStatus, MsgIDTable Name : Message_IdentifierField Name : MsgID, TotalCountRequirement: I have 100 records in the table for the MsgID 111, I need to calculate time taken to process 80% of records. That will be the difference between SubmitDate for the 1st record and 80th record.Issue : In the below query MIN(DMQD.SubmitDate) takes the first record but MAX(DMQD.SubmitDate) takes the 100th record which is wrong. select TOP (select ((MD.TotalCount*80)/100) as TotalCount from [dbo].[Message_Identifier] MD where MD.MessageID = 1141) DATEDIFF(SECOND,MIN(DMQD.SubmitDate), MAX(DMQD.SubmitDate)) as TimeDiff from [dbo]. message_queue_details DMM DMM.MessageID = 1141Can anyone help me to provide a single query because this i need to put it in different query for reporting

Viewing all articles
Browse latest Browse all 3145

Trending Articles