联盟进入新表问题

时间:2016-01-19 19:10:19

标签: ms-access union

我有这3个查询。我需要将三个查询的结果合并并添加到名为" Overall_Rating"的新表中。我尝试将它们全部联合起来,用于查看数据。然而,当尝试INTO" Overall_Rating"它不会让我失望,因为它说它是一个动作查询。如何将所有这些查询的结果添加到一个新表中?

以下是查询:

SELECT ST.pipe_segment_reference,
       IIF(ST.structural_peak > OM.o_m_peak, ST.structural_peak, OM.o_m_peak) AS Overall_Peak,
       ST.structural_score + OM.o_m_score AS Overall_Score,
       ST.structural_defects + OM.o_m_defects AS Overall_Defects,
       ROUND(Overall_Score / Overall_Defects, 1) AS Overall_Index
FROM structural_rating AS ST
INNER JOIN o_m_rating AS OM ON OM.pipe_segment_reference = ST.pipe_segment_reference;

SELECT ST.pipe_segment_reference,
       ST.structural_peak AS Overall_Peak,
       ST.structural_score AS Overall_Score,
       ST.structural_defects AS Overall_Defects,
       ST.structural_index AS Overall_Index
FROM structural_rating AS ST
LEFT JOIN o_m_rating AS OM ON OM.pipe_segment_reference = ST.pipe_segment_reference
WHERE OM.pipe_segment_reference IS NULL;

SELECT OM.pipe_segment_reference,
       OM.o_m_peak AS Overall_Peak,
       OM.o_m_score AS Overall_Score,
       OM.o_m_defects AS Overall_Defects,
       OM.o_m_index AS Overall_Index
FROM o_m_rating AS OM
LEFT JOIN structural_rating AS ST ON OM.pipe_segment_reference = ST.pipe_segment_reference
WHERE ST.pipe_segment_reference IS NULL;

1 个答案:

答案 0 :(得分:1)

创建联合查询并将其用作新make表或追加查询的基础。