insert into #tmpImportTruckMin( Month, Count, ID, ContainerSize, TruckTime, ContainerOrder ) values ( ( SELECT (case when @monthnoImportTime = 1 then 'Jan' when @monthnoImportTime = 2 then 'Feb' when @monthnoImportTime = 3 then 'Mar' when @monthnoImportTime= 4 then 'Apr' when @monthnoImportTime = 5 then 'May' when @monthnoImportTime= 6 then 'Jun' when @monthnoImportTime = 7 then 'Jul' when @monthnoImportTime= 8 then 'Aug' when @monthnoImportTime = 9 then 'Sep' when @monthnoImportTime = 10 then 'Oct' when @monthnoImportTime = 11 then 'Nov' when @monthnoImportTime = 12 then 'Dec' end ), ISNULL(COUNT(GatePassId),0), @monthnoImportTime, '20FT', AVG( CASE WHEN Status = 'In Yard' thenISNULL(DATEDIFF(MINUTE,TimeIn,getdate()),0) when status = 'Left The Yard' then ISNULL(DATEDIFF(MINUTE,TimeIn,TimeOut),0) else '0' end ), 1 from tbl_CMS_GatePass where MONTH(AddedTime) = @monthnoImportTime and YEAR(AddedTime) = @Year and DepotID =@DepotID and BranchID = @branchID AND ((ShippingLine IS NULL OR ShippingLine=0) AND (@ShippingLine IS NULL OR @ShippingLine=0) OR ShippingLine= CASE WHEN ((@ShippingLine=0) OR (@ShippingLine IS NULL)) THEN ShippingLine ELSE @ShippingLine END) and ((Customer IS NULL OR Customer=0) AND (@Client IS NULL OR @Client=0) OR Customer= CASE WHEN ((@Client=0) OR (@Client IS NULL)) THEN Customer ELSE @Client END) and ContainerSize = 2))
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)