Products are grouped to check and pass / fail on approximately 20 criteria. They need a report that indicates how many of each defect belong to a separate group.
Defect * is varchar (3) and is used to determine which criteria failed.
There are 3 columns for defects in the table, and I can return them with something like:
SELECT GroupID,
Defect1, COUNT(Defect1) as Occ1,
Defect2, COUNT(Defect2) as Occ2,
Defect3, COUNT(Defect3) as Occ3
FROM Product
WHERE Run = 1728 AND Defect1 IS NOT NULL
GROUP BY GroupID, Defect1, Defect2, Defect3
ORDER BY GroupID
Which gives a conclusion, for example:
GroupID Def1 Occ1 Def2 Occ2 Def3 Occ3
RF-061 CPP 1 FPV 1 null 0
RF-061 FPV 1 CPP 1 null 0
RF-061 HCR 1 CHP 1 null 0
RF-061 CHP 1 FPV 1 null 0
RF-061 FBL 1 HCR 1 FPT 1
RF-061 CHP 1 CPP 1 HCR 1
RF-061 CHP 1 CPP 1 null 0
RF-061 CPP 1 FBL 1 null 0
...
Required Conclusion:
GrPupID Def Occurrences
BF-061 FPV 4
BF-061 CPP 5
BF-061 CHP 5
BF-061 HCR 5
BF-061 FBL 3
BF-061 PPC 1
BF-061 FPT 1
on SQL Server 7, yes, I know.
source
share