J
Jay Balapa
Hello,
I have two tables-
TBLHISTORY with the following fields-
BARCODE ITEMTYPE PASS DATEINSPECTED
1000 x YES 01/12/2004
1000 x YES 06/12/2004
1000 x NO 01/12/2005
1000 x NO 06/12/2005
1000 x YES 01/12/2006
1001 x YES 02/12/2004
1001 x YES 02/12/2005
1001 x YES 02/12/2006
1002 x NO 03/12/2004
1002 x YES 03/12/2005
1002 x YES 03/12/2006
1003 y YES 04/12/2004
1003 y YES 04/12/2005
1003 y NO 04/12/2006
1004 y YES 05/12/2004
1004 y YES 06/12/2004
1004 y YES 05/12/2005
1004 y YES 08/12/2005
1004 y YES 05/12/2006
1005 z NO 06/12/2004
1005 z NO 06/12/2005
1005 z YES 06/12/2006
TBLINSPECTIONPERIOD lists all the inspection periods for each itemtype
ITEMTYPE STARTPERIOD ENDPERIOD
x 01/01/2004 12/31/2004
x 01/01/2005 12/31/2005
x 01/01/2006 12/31/2006
y 01/01/2004 12/31/2004
y 01/01/2005 12/31/2005
y 01/01/2006 12/31/2006
z 01/01/2004 12/31/2004
z 01/01/2005 12/31/2005
z 01/01/2006 12/31/2006
Iam trying to create a summary resultset which has the following-
ITEMTYPE STARTPERIOD ENDPERIOD [# of items Inspected] [# of
Items Passed] [Percentage Passed]
x 01/01/2004 12/31/2004 3
2 66%
x 01/01/2005 12/31/2005 3
1 33%
x 01/01/2006 12/31/2006 3
3 100%
y 01/01/2004 12/31/2004 2
2 100%
y 01/01/2005 12/31/2005 2
2 100%
y 01/01/2006 12/31/2006 2
1 50%
z 01/01/2004 12/31/2004 1
0 0%
z 01/01/2005 12/31/2005 1
0 0%
z 01/01/2006 12/31/2006 1
1 100%
- Iam trying to group the ItemTypes in tblhistory into the corresponding
InspectionPeriod based
on the Inspectiondates.
- We get Sum of all uniquevItems Inspected for each ItemType which falls
under each InspectionPeriod.
- If an item is inspected more than once during an Inspection Period only
the most recent result is taken and older
inspection is discarded. Then we get the number of items passed. Finally
the Pass %.
Can this be accomplished in a single statement or combination of tableview
and single statement Will I need a stored procedure to accomplish this
task?
Any help will be greatly appreciated.
Thanks
Jay
I have two tables-
TBLHISTORY with the following fields-
BARCODE ITEMTYPE PASS DATEINSPECTED
1000 x YES 01/12/2004
1000 x YES 06/12/2004
1000 x NO 01/12/2005
1000 x NO 06/12/2005
1000 x YES 01/12/2006
1001 x YES 02/12/2004
1001 x YES 02/12/2005
1001 x YES 02/12/2006
1002 x NO 03/12/2004
1002 x YES 03/12/2005
1002 x YES 03/12/2006
1003 y YES 04/12/2004
1003 y YES 04/12/2005
1003 y NO 04/12/2006
1004 y YES 05/12/2004
1004 y YES 06/12/2004
1004 y YES 05/12/2005
1004 y YES 08/12/2005
1004 y YES 05/12/2006
1005 z NO 06/12/2004
1005 z NO 06/12/2005
1005 z YES 06/12/2006
TBLINSPECTIONPERIOD lists all the inspection periods for each itemtype
ITEMTYPE STARTPERIOD ENDPERIOD
x 01/01/2004 12/31/2004
x 01/01/2005 12/31/2005
x 01/01/2006 12/31/2006
y 01/01/2004 12/31/2004
y 01/01/2005 12/31/2005
y 01/01/2006 12/31/2006
z 01/01/2004 12/31/2004
z 01/01/2005 12/31/2005
z 01/01/2006 12/31/2006
Iam trying to create a summary resultset which has the following-
ITEMTYPE STARTPERIOD ENDPERIOD [# of items Inspected] [# of
Items Passed] [Percentage Passed]
x 01/01/2004 12/31/2004 3
2 66%
x 01/01/2005 12/31/2005 3
1 33%
x 01/01/2006 12/31/2006 3
3 100%
y 01/01/2004 12/31/2004 2
2 100%
y 01/01/2005 12/31/2005 2
2 100%
y 01/01/2006 12/31/2006 2
1 50%
z 01/01/2004 12/31/2004 1
0 0%
z 01/01/2005 12/31/2005 1
0 0%
z 01/01/2006 12/31/2006 1
1 100%
- Iam trying to group the ItemTypes in tblhistory into the corresponding
InspectionPeriod based
on the Inspectiondates.
- We get Sum of all uniquevItems Inspected for each ItemType which falls
under each InspectionPeriod.
- If an item is inspected more than once during an Inspection Period only
the most recent result is taken and older
inspection is discarded. Then we get the number of items passed. Finally
the Pass %.
Can this be accomplished in a single statement or combination of tableview
and single statement Will I need a stored procedure to accomplish this
task?
Any help will be greatly appreciated.
Thanks
Jay