Hello everyone, there is such a tour of a certain company
CREATE TABLE Country_destination( id int NOT NULL, Name varchar(255) NOT NULL, CONSTRAINT Country_destinationPK PRIMARY KEY (id)); CREATE TABLE City( id int NOT NULL, Name varchar(255) NOT NULL, CONSTRAINT CityPK PRIMARY KEY(id)); CREATE TABLE Tour( id int NOT NULL, Price int NOT NULL, Date date NOT NULL, Time_Tour timestamp NOT NULL, Cityid int NULL, CONSTRAINT TourPK PRIMARY KEY(id), CONSTRAINT Tour_CityidFK FOREIGN KEY (Cityid) REFERENCES City (id)); CREATE TABLE Client( id int NOT NULL, Firstname varchar(255) NOT NULL, Secondname varchar(255) NOT NULL, Number int NOT NULL, CONSTRAINT ClientPK PRIMARY KEY(id)); CREATE TABLE Type_Transport( id int NOT NULL, Name varchar(255) NULL, CONSTRAINT Type_TransportPK PRIMARY KEY (id)); CREATE TABLE Treaty( id int NOT NULL, Number int NULL, Tourid int NULL, Clientid int NULL, Type_Transportid int NULL, CONSTRAINT TreatyPK PRIMARY KEY(id), CONSTRAINT Treaty_TouridFK FOREIGN KEY (Tourid) REFERENCES Tour (id), CONSTRAINT Treaty_ClientidFK FOREIGN KEY (Clientid) REFERENCES Client (id), CONSTRAINT Treaty_Type_TransportidFK FOREIGN KEY (Type_Transportid) REFERENCES Type_Transport (id)); CREATE SEQUENCE SEQ_Country_destination INCREMENT BY 1 START WITH 1; CREATE SEQUENCE SEQ_City INCREMENT BY 1 START WITH 1; CREATE SEQUENCE SEQ_Tour INCREMENT BY 1 START WITH 1; CREATE SEQUENCE SEQ_Client INCREMENT BY 1 START WITH 1; INSERT INTO Country_destination VALUES (nextVal('seq_country_destination'),'Russia'); INSERT INTO Country_destination VALUES (nextVal('seq_country_destination'),'USA'); INSERT INTO Country_destination VALUES (nextVal('seq_country_destination'),'Egypt'); INSERT INTO City VALUES (nextVal('seq_city'),'Moscow'); INSERT INTO City VALUES (nextVal('seq_city'),'Washington'); INSERT INTO City VALUES (nextVal('seq_city'),'Kair'); INSERT INTO Tour VALUES (nextVal('seq_tour'),10000,'27.11.2017', '23:15'); INSERT INTO Tour VALUES (nextVal('seq_tour'),15000,'28.12.2017', '14:15'); INSERT INTO Tour VALUES (nextVal('seq_tour'),20000,'29.07.2017', '22:10'); INSERT INTO Client VALUES (nextVal('seq_city'),'Vasili','Ivanov', 612716); INSERT INTO Client VALUES (nextVal('seq_city'),'Ivan','Fedorov', 123456); INSERT INTO Client VALUES (nextVal('seq_city'),'Ilya','Sidorov', 654321); SELECT*FROM Client WHERE number='612716'; SELECT*FROM Client ORDER BY Firstname; SELECT*FROM Client ORDER BY Firstname DESC; SELECT number FROM Client WHERE id IN( SELECT Clientid FROM Treaty); How to write such requests, I am new to this, and I can’t (1) bring out the top 10 popular places (the most frequent cities where they fly to) 2) and places for the coming summer (finding who goes to the near summer) will thank you if you tell me