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
| SELECT DisplayName AS antennes, Sum(c1) AS keyboard, Sum(c2) AS OHScanner, Sum(c3) AS HHScanner, Sum(c4) AS Stray, Sum(c5) AS Fragile, Sum(c6) AS Cylindrical, Sum(c7) AS OverSize, Sum(c1)+Sum(c2)+Sum(c4)+Sum(c5)+Sum(c6)+Sum(c7) AS Total
FROM (SELECT dbo_vwParts.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=dbo_vwParts.ID
where ( dbo_vwItemEventHistory.ItemEventTypeId=5) AND (dbo_vwItemEventHistory.EventTime>=#4/25/2014 10:0:0#) And (dbo_vwItemEventHistory.EventTime<=#4/25/2014 11:0:0#) AND( id.inductionMode='Keyboard')
Group BY p.DisplayName
Union
SELECT p.DisplayName,0 AS c1, 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>=#4/25/2014 10:0:0#) And (dbo_vwItemEventHistory.EventTime<=#4/25/2014 11:0:0#) AND( id.inductionMode='scanner')
Group BY p.DisplayName
UNION
SELECT p.Displayname,0 AS c1, 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>=#4/25/2014 10:0:0#) And (dbo_vwItemEventHistory.EventTime<=#4/25/2014 11:0:0#) AND( id.inductionMode='HHScanner')
Group BY p.DisplayName
UNION
SELECTdbo_vwParts.Displayname,0 AS c1, 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>=#4/25/2014 10:0:0#) And (dbo_vwItemEventHistory.EventTime<=#4/25/2014 11:0:0#) AND( id.inductionMode='Stray')
Group BY p.DisplayName
UNION
SELECT dbo_vwParts.Displayname,0 AS c1, 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>=#4/25/2014 10:0:0#) And (dbo_vwItemEventHistory.EventTime<=#4/25/2014 11:0:0#) AND( id.inductionMode='fragile')
Group BY p.DisplayName
UNION
SELECT dbo_vwParts.Displayname,0 AS c1, count (*) 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 ( dbo_vwPartCountsHistory.CounterTypeId=82/*Cylindrical*/) AND (dbo_vwPartCountsHistory.CounterTimeStamp>=#4/25/2014 10:0:0#) AND (dbo_vwPartCountsHistory.CounterTimeStamp<=#4/25/2014 11:0:0#)
Group BY dbo_vwParts
UNION
SELECT p.Displayname,0 AS c1, count (*) AS c1,0 AS c2,0 As c3,0 AS c4,0 As c5, 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 ( dbo_vwPartCountsHistory.CounterTypeId=83/*OverSizel*/) AND (dbo_vwPartCountsHistory.CounterTimeStamp>=#4/25/2014 10:0:0#) AND (dbo_vwPartCountsHistory.CounterTimeStamp<=#4/25/2014 11:0:0#)
Group BY dbo_vwParts.Displayname) AS tbl GROUP BY DisplayName
ORDER BY DisplayName; |
Partager