我在toad中运行查询以测试结果,但我收到错误
ORA-00933:SQL命令未正确结束
这是我的查询
SELECT DISTINCT sv.mkey, vehicle_no, 'ABC' isnullcheck,
TO_CHAR (date_in, 'dd-MM-yyyy')
|| ' & '
|| time_in vehicleindate_time,
TO_CHAR (date_out, 'dd-MM-yyyy')
|| ' & '
|| time_out vehicleoutdate_time,
gate_no_in || ' & ' || gate_no_out ingate_outgateno,
gd.good_type goods_type, net_weight netweight,
TO_CHAR (challan_date, 'dd-MM-yyyy')
|| ' & '
|| challan_no challandate_no,
remark_in remarkin, NULL receipt_no, date_in
FROM xxcus.xxgid_supinv sv,
xxcus.xx_supinv_goodtype gd,
xxcus.xxacl_xxgid_user_mst ms
WHERE gd.good_type_code(+) = sv.good_type
AND sv.project_id = 1368
AND (sv.audit_flag IS NULL OR sv.audit_flag = 'N') UNION SELECT DISTINCT sv.mkey, vehicle_no, 'XYZ' portfolio,
TO_CHAR (date_in, 'dd-MM-yyyy')
|| ' & '
|| time_in vehicleindate_time,
TO_CHAR (date_out, 'dd-MM-yyyy')
|| ' & '
|| time_out vehicleoutdate_time,
gate_no_in || ' & ' || gate_no_out ingate_outgateno,
gd.good_type goods_type, net_weight netweight,
TO_CHAR (challan_date, 'dd-MM-yyyy')
|| ' & '
|| challan_no challandate_no,
remark_in remarkin, NULL receipt_no, date_in
FROM xxcus.xxgid_supinv sv,
xxcus.xx_supinv_goodtype gd,
xxcus.xxacl_xxgid_user_mst ms
WHERE gd.good_type_code(+) = sv.good_type
AND sv.project_id = 1368
AND sv.audit_flag IS NULL
ORDER BY isnullcheck, date_in DESC, vehicle_no UNION
SELECT NULL, 0, 'ABC', NULL, NULL, NULL,
'ABC', NULL, NULL, NULL, NULL, NULL, NULL
FROM DUAL
UNION
SELECT NULL, 0, 'XYZ', NULL, NULL, NULL,
'XYZ', NULL, NULL, NULL, NULL, NULL, NULL
FROM DUAL
请告知这里有什么问题
答案 0 :(得分:1)
你的两个较大的SELECTS(前2个)将返回12个项目。最后两个SELECTS(小的)返回13个项目。 UNION必须有匹配的列。
例如声明应该结束......
SELECT NULL, 0, 'ABC', NULL, NULL, NULL,
'ABC', NULL, NULL, NULL, NULL, NULL
FROM DUAL
UNION
SELECT NULL, 0, 'XYZ', NULL, NULL, NULL,
'XYZ', NULL, NULL, NULL, NULL, NULL
FROM DUAL