UNION ALL ではなく UNION クエリを使用すると、オーバーフロー エラーが発生するのはなぜですか?? UNION の各側のクエリはそれ自体で正常に機能し、各クエリが作用するテーブルは同一です。つまり、ライブ データ テーブルとアーカイブ データ テーブルはまったく同じ構造を持ちます。
クエリ作品:
SELECT Format(CVDate([DateID] & " " & [TimeID]),"yyyy/mm/dd hh:nn:ss") & "-" & [RecNum] AS DateTimeRecNumID,
[QC Records].WONum,
[QC Records].InspName1,
[QC Records].QtyInsp,
Nz([008],0)+Nz([011],0)+Nz([012],0)+Nz([013],0)+Nz([014],0)+Nz([015],0)+Nz([016],0)+Nz([017],0)+Nz([018],0)+Nz([019],0)+Nz([020],0)+Nz([022],0)+Nz([023],0)+Nz([029],0)+Nz([035],0)+Nz([036],0)+Nz([037],0)+Nz([040],0)+Nz([041],0)+Nz([044],0)+Nz([045],0)+Nz([046],0)+Nz([047],0)+Nz([048],0)+Nz([050],0)+Nz([052],0)+Nz([055],0)+Nz([057],0)+Nz([059],0)+Nz([060],0)+Nz([062],0)+Nz([064],0)+Nz([066],0)+Nz([070],0)+Nz([072],0)+Nz([075],0)+Nz([077],0)+Nz([080],0)+Nz([081],0)+Nz([082],0)+Nz([083],0)+Nz([084],0)+Nz([085],0)+Nz([086],0)+Nz([088],0)+Nz([095],0)+Nz([096],0)+Nz([097],0)+Nz([111],0)+Nz([113],0)+Nz([115],0)+Nz([116],0)+Nz([117],0)+Nz([118],0)+Nz([119],0)+Nz([120],0)+Nz([121],0)+Nz([122],0)+Nz([123],0)+Nz([124],0)+Nz([125],0)+Nz([126],0)+Nz([127],0)+Nz([128],0)+Nz([129],0)+Nz([130],0)+Nz([130],0) AS SumFaults,
1-([SumFaults]/[QtyInsp]) AS PassRate,
[QC Records].ItemNum
FROM [QC Records]
WHERE ((([QC Records].ProdSrc)="Production"))
UNION ALL
SELECT Format(CVDate([DateID] & " " & [TimeID]),"yyyy/mm/dd hh:nn:ss") & "-" & [RecNum] AS DateTimeRecNumID,
[QC Records (Archive)].WONum,
[QC Records (Archive)].InspName1,
[QC Records (Archive)].QtyInsp,
Nz([008],0)+Nz([011],0)+Nz([012],0)+Nz([013],0)+Nz([014],0)+Nz([015],0)+Nz([016],0)+Nz([017],0)+Nz([018],0)+Nz([019],0)+Nz([020],0)+Nz([022],0)+Nz([023],0)+Nz([029],0)+Nz([035],0)+Nz([036],0)+Nz([037],0)+Nz([040],0)+Nz([041],0)+Nz([044],0)+Nz([045],0)+Nz([046],0)+Nz([047],0)+Nz([048],0)+Nz([050],0)+Nz([052],0)+Nz([055],0)+Nz([057],0)+Nz([059],0)+Nz([060],0)+Nz([062],0)+Nz([064],0)+Nz([066],0)+Nz([070],0)+Nz([072],0)+Nz([075],0)+Nz([077],0)+Nz([080],0)+Nz([081],0)+Nz([082],0)+Nz([083],0)+Nz([084],0)+Nz([085],0)+Nz([086],0)+Nz([088],0)+Nz([095],0)+Nz([096],0)+Nz([097],0)+Nz([111],0)+Nz([113],0)+Nz([115],0)+Nz([116],0)+Nz([117],0)+Nz([118],0)+Nz([119],0)+Nz([120],0)+Nz([121],0)+Nz([122],0)+Nz([123],0)+Nz([124],0)+Nz([125],0)+Nz([126],0)+Nz([127],0)+Nz([128],0)+Nz([129],0)+Nz([130],0)+Nz([130],0) AS SumFaults,
1-([SumFaults]/[QtyInsp]) AS PassRate,
[QC Records (Archive)].ItemNum
FROM [QC Records (Archive)]
WHERE ((([QC Records (Archive)].ProdSrc)="Production"));
機能しません (違いは UNION の後の「ALL」です:
SELECT Format(CVDate([DateID] & " " & [TimeID]),"yyyy/mm/dd hh:nn:ss") & "-" & [RecNum] AS DateTimeRecNumID,
[QC Records].WONum,
[QC Records].InspName1,
[QC Records].QtyInsp,
Nz([008],0)+Nz([011],0)+Nz([012],0)+Nz([013],0)+Nz([014],0)+Nz([015],0)+Nz([016],0)+Nz([017],0)+Nz([018],0)+Nz([019],0)+Nz([020],0)+Nz([022],0)+Nz([023],0)+Nz([029],0)+Nz([035],0)+Nz([036],0)+Nz([037],0)+Nz([040],0)+Nz([041],0)+Nz([044],0)+Nz([045],0)+Nz([046],0)+Nz([047],0)+Nz([048],0)+Nz([050],0)+Nz([052],0)+Nz([055],0)+Nz([057],0)+Nz([059],0)+Nz([060],0)+Nz([062],0)+Nz([064],0)+Nz([066],0)+Nz([070],0)+Nz([072],0)+Nz([075],0)+Nz([077],0)+Nz([080],0)+Nz([081],0)+Nz([082],0)+Nz([083],0)+Nz([084],0)+Nz([085],0)+Nz([086],0)+Nz([088],0)+Nz([095],0)+Nz([096],0)+Nz([097],0)+Nz([111],0)+Nz([113],0)+Nz([115],0)+Nz([116],0)+Nz([117],0)+Nz([118],0)+Nz([119],0)+Nz([120],0)+Nz([121],0)+Nz([122],0)+Nz([123],0)+Nz([124],0)+Nz([125],0)+Nz([126],0)+Nz([127],0)+Nz([128],0)+Nz([129],0)+Nz([130],0)+Nz([130],0) AS SumFaults,
1-([SumFaults]/[QtyInsp]) AS PassRate,
[QC Records].ItemNum
FROM [QC Records]
WHERE ((([QC Records].ProdSrc)="Production"))
UNION
SELECT Format(CVDate([DateID] & " " & [TimeID]),"yyyy/mm/dd hh:nn:ss") & "-" & [RecNum] AS DateTimeRecNumID,
[QC Records (Archive)].WONum,
[QC Records (Archive)].InspName1,
[QC Records (Archive)].QtyInsp,
Nz([008],0)+Nz([011],0)+Nz([012],0)+Nz([013],0)+Nz([014],0)+Nz([015],0)+Nz([016],0)+Nz([017],0)+Nz([018],0)+Nz([019],0)+Nz([020],0)+Nz([022],0)+Nz([023],0)+Nz([029],0)+Nz([035],0)+Nz([036],0)+Nz([037],0)+Nz([040],0)+Nz([041],0)+Nz([044],0)+Nz([045],0)+Nz([046],0)+Nz([047],0)+Nz([048],0)+Nz([050],0)+Nz([052],0)+Nz([055],0)+Nz([057],0)+Nz([059],0)+Nz([060],0)+Nz([062],0)+Nz([064],0)+Nz([066],0)+Nz([070],0)+Nz([072],0)+Nz([075],0)+Nz([077],0)+Nz([080],0)+Nz([081],0)+Nz([082],0)+Nz([083],0)+Nz([084],0)+Nz([085],0)+Nz([086],0)+Nz([088],0)+Nz([095],0)+Nz([096],0)+Nz([097],0)+Nz([111],0)+Nz([113],0)+Nz([115],0)+Nz([116],0)+Nz([117],0)+Nz([118],0)+Nz([119],0)+Nz([120],0)+Nz([121],0)+Nz([122],0)+Nz([123],0)+Nz([124],0)+Nz([125],0)+Nz([126],0)+Nz([127],0)+Nz([128],0)+Nz([129],0)+Nz([130],0)+Nz([130],0) AS SumFaults,
1-([SumFaults]/[QtyInsp]) AS PassRate,
[QC Records (Archive)].ItemNum
FROM [QC Records (Archive)]
WHERE ((([QC Records (Archive)].ProdSrc)="Production"));
エラーは「オーバーフロー」です
また、UNION ALLクエリでSELECT DISTINCTクエリを実行しようとしましたが、「オーバーフロー」エラーも発生しています...??