当我单独运行子查询时,我得到每行的唯一日期,但我一起得到重复的行。我该如何纠正?
SELECT a.*
,b.*
FROM (
SELECT DISTINCT serial_number_id
,s_start_dttm
,x_dept_id AS dept_a
,x_dept_name AS dept_name_a
,event_type_c AS event_type_a
,evnt.NAME AS event_name_a
FROM TABLE x
WHERE event_type_c = 3
) a
,(
SELECT DISTINCT serial_number_id
,s_end_dttm
,x_dept_id AS E_x_DEPT_ID
,x_DEPT_NAME AS E_x_DEPT_NAME
,event_type_c AS event_type_b
,event_name AS event_type_b
WHERE event_type_c = 4
) b
WHERE a.serial_number_id = b.serial_number_id