Brett,The table DDL is as mentioned below and is using a Clustered Index as well.CREATE TABLE [ImportData] ( [BranchID] [int] NULL , [BranchName] [char] (13) COLLATE Latin1_General_CI_AS NULL , [BranchType] [nvarchar] (100) COLLATE Latin1_General_CI_AS NULL , [BranchTypeId] [int] , [BranchCode] [char] (5) COLLATE Latin1_General_CI_AS NULL , [Location] [nvarchar] (100) COLLATE Latin1_General_CI_AS NULL , [DatabaseDateTime] [datetime] NULL , [ScanDateTime] [datetime] NULL) ON [PRIMARY]CREATE CLUSTERED INDEX CX_ImportData ON dbo.ImportData ( BranchCode, ScanDateTime ) ON [PRIMARY]
However, in the output i do not want all fields (only the one's mentioned in the Expected Output above).I want this to be implemented for about 25000 BranchID and about 1900 Locations i.e. each location will be shown having their respective BranchID's (as shown in the expected output above).Longest Elapsed Time = "DatabaseDateTime" - "ScanDateTime"Average Elapsed Time = Avg(Longest Elapsed Time) for every location level.Items = Total no of BranchCodes received by every BranchIDSanchit.