Take out the recurring passenger train frequency
SELECT CID, From_city, to_city, Ticket_price
From city
WHERE CID in (SELECT DISTINCT first_value (CCID) through (PARTITION by from_city, To_city ORDER by from_city, to_city)
From (SELECT a.cid CCID,
A.from_city From_city,
A.to_city To_city,
A.ticket_price Price
From City A
UNION All
SELECT B.cid CCID,
B.to_city From_city,
B.from_city To_city,
B.ticket_price Price
From City B
ORDER by From_city, to_city))
CREATE TABLE City (CID number,from_city VARCHAR2, To_city VARCHAR2 (), ticket_price number)
INSERT into city (Cid,from_city,to_city,ticket_price)
SELECT,' Beijing ',' Shanghai ', from dual
UNION All
SELECT 02, ' Shanghai ', ' Shenzhen ', 280 from dual
UNION All
SELECT 03, ' Wuhan ', ' Guangzhou ', from dual
UNION All
SELECT 04, ' Xian ', ' Chengdu ', from dual
UNION All
SELECT 05, ' Shenzhen ', ' Shenzhen ', from dual
UNION All
SELECT,' Shanghai ',' Beijing ', from dual
UNION All
SELECT 07, ' Guangzhou ', ' Wuhan ', from dual
UNION All
SELECT 08, ' Shenzhen ', ' Shanghai ', 280 from dual
UNION All
SELECT 09, ' Chengdu ', ' Chongqing ', from dual
COMMIT;
Remove duplicate passenger train shifts, value interchange of two fields as duplicate values