显示所有客户,以及他们所有的 payment_schedules
select PS.Event_ID, PS.Event_Type, PS.Event_Incharge, PS.Event_Date, PA.Customer_ID
from (Product_AMC PA
inner join Payment_Schedule PS on (PS.Event_Type='AMC' and PS.Event_ID=PA.AMC_ID))
union all
select PS.Event_ID, PS.Event_Type, PS.Event_Incharge, PS.Event_Date, IO.Customer_ID
from (Item_Order IO
inner join Payment_Schedule PS on (PS.Event_Type='Order' and PS.Event_ID=IO.Order_ID))
order by Customer_ID
对于单个客户,说“ABC”
select PS.Event_ID, PS.Event_Type, PS.Event_Incharge, PS.Event_Date, PA.Customer_ID
from (Product_AMC PA
inner join Payment_Schedule PS on (PS.Event_Type='AMC' and PS.Event_ID=PA.AMC_ID))
where PA.Customer_ID = 'ABC'
union all
select PS.Event_ID, PS.Event_Type, PS.Event_Incharge, PS.Event_Date, IO.Customer_ID
from (Item_Order IO
inner join Payment_Schedule PS on (PS.Event_Type='Order' and PS.Event_ID=IO.Order_ID))
where IO.Customer_ID = 'ABC'