1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| PARAMETERS [date debut] DateTime, [date fin] DateTime;
SELECT tbl.DisplayName, Sum(tbl.c1) AS keyboard, Sum(tbl.c2) AS Scanner, Sum(tbl.c3) AS HHScanner, Sum(tbl.c4) AS Stray, Sum(tbl.c5) AS Fragile, Sum(tbl.c6) AS Cylindrical, Sum(tbl.c7) AS OverSize, Sum(c1)+Sum(c2)+Sum(c3)+Sum(c4)+Sum(c5)+Sum(c6)+Sum(c7) AS Total, CLng(total*60/(DateDiff("n",[date debut],[date fin]))) AS nombre_colis_heure, [date debut] AS date_debut, [date fin] AS date_fin
FROM (SELECT p.DisplayName, count(*) AS c1, 0 AS c2, 0 As c3, 0 AS c4, 0 As c5, 0 AS c6, 0 As c7, 0 AS c8, 0 AS c9
FROM (dbo_vwItemEventHistory INNER JOIN dbo_vwItemData AS id ON dbo_vwItemEventHistory.ItemID = id.ItemID) INNER JOIN dbo_vwParts AS p ON id.InductionPartID = p.ID
where (dbo_vwItemEventHistory.ItemEventTypeID = 5) AND (dbo_vwItemEventHistory.EventTime>=[date debut]) And (dbo_vwItemEventHistory.EventTime<=[date fin]) AND (id.InductionMode='Keyboard')
AND id.dischargePartId <> 3645
GROUP BY p.DisplayName
UNION
SELECT p.DisplayName, 0 AS c1, 0 AS c2, 0 As c3, 0 AS c4, 0 As c5, Sum(CounterValue) AS c6, 0 AS c7, 0 AS c8, 0 AS c9
FROM dbo_vwPartCountsHistory AS ch INNER JOIN dbo_vwParts AS p ON ch.partId = p.ID
where (CounterTypeId = 82) AND (CounterTimeStamp>=[date debut]) And (CounterTimeStamp<=[date fin])
GROUP BY p.DisplayName
UNION
SELECT p.DisplayName, 0 AS c1, count (*) AS c2, 0 As c3 , 0 AS c4, 0 As c5, 0 AS c6, 0 As c7 ,0 AS c8, 0 AS c9
FROM (dbo_vwItemEventHistory INNER JOIN dbo_vwItemData AS id on dbo_vwItemEventHistory.itemID = id.itemID) INNER JOIN dbo_vwParts as p ON id.inductionPartId = p.id
where (dbo_vwItemEventHistory.ItemEventTypeId = 5) AND (dbo_vwItemEventHistory.EventTime>=[date debut]) And (dbo_vwItemEventHistory.EventTime<=[date fin]) AND ( id.inductionMode='scanner')
AND id.dischargePartId <> 3645
GROUP BY p.DisplayName
UNION
SELECT p.DisplayName, 0 AS c1, 0 AS c2, count (*) As c3, 0 AS c4, 0 As c5, 0 AS c6, 0 As c7, 0 AS c8, 0 AS c9
FROM (dbo_vwItemEventHistory INNER JOIN dbo_vwItemData AS id ON dbo_vwItemEventHistory.itemid = id.itemid) INNER JOIN dbo_vwParts as p ON id.inductionPartId = p.id
where (dbo_vwItemEventHistory.ItemEventTypeId = 5) AND (dbo_vwItemEventHistory.EventTime>=[date debut]) And (dbo_vwItemEventHistory.EventTime<=[date fin]) AND ( id.inductionMode='HHScanner')
AND id.dischargePartId <> 3645
GROUP BY p.DisplayName
UNION
SELECT p.DisplayName, 0 AS c1, 0 AS c2, 0 AS c3, count (*) AS c4, 0 As c5, 0 AS c6, 0 As c7, 0 AS c8, 0 AS c9
FROM (dbo_vwItemEventHistory INNER JOIN dbo_vwItemData AS id ON dbo_vwItemEventHistory.itemid = id.itemid ) INNER JOIN dbo_vwParts AS p ON id.inductionPartId = p.id
where (dbo_vwItemEventHistory.ItemEventTypeId = 5) AND (dbo_vwItemEventHistory.EventTime>=[date debut]) And (dbo_vwItemEventHistory.EventTime<=[date fin]) AND ( id.inductionMode='Stray')
AND id.dischargePartId <> 3645
GROUP BY p.DisplayName
UNION
SELECT p.DisplayName, 0 AS c1, 0 AS c2, 0 As c3, 0 AS c4, count (*) As c5, 0 AS c6, 0 As c7, 0 AS c8, 0 AS c9
FROM (dbo_vwItemEventHistory INNER JOIN dbo_vwItemData AS id ON dbo_vwItemEventHistory.itemid=id.itemid)INNER JOIN dbo_vwParts AS p ON id.inductionPartId = p.id
where (dbo_vwItemEventHistory.ItemEventTypeId=5) AND (dbo_vwItemEventHistory.EventTime>=[date debut]) And (dbo_vwItemEventHistory.EventTime<=[date fin]) AND ( id.inductionMode='fragile')
AND id.dischargePartId <> 3645
GROUP BY p.DisplayName
UNION ALL
SELECT p.DisplayName, 0 AS c1, 0 AS c2, 0 As c3, 0 AS c4, 0 As c5, 0 AS c6, Sum(CounterValue) AS c7, 0 AS c8, 0 AS c9
FROM dbo_vwPartCountsHistory AS ch INNER JOIN dbo_vwParts AS p ON ch.partId = p.ID
where (CounterTypeId = 83) AND (CounterTimeStamp>=[date debut]) and (CounterTimeStamp<=[date fin])
GROUP BY p.DisplayName) tbl
GROUP BY tbl.DisplayName
ORDER BY tbl.DisplayName |
Partager