NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

-- Create the travel table
CREATE TABLE travel (
agent_name VARCHAR(100),
agent_id VARCHAR(100),
flight_city VARCHAR(100),
booking_assignment VARCHAR(100),
passenger_id VARCHAR(100),
flight_no INT,
PRIMARY KEY (passenger_id),
FOREIGN KEY (passenger_id) REFERENCES passenger(passenger_id)
);

-- Create the passenger table
CREATE TABLE passenger (
passenger_id VARCHAR(100),
passenger_name VARCHAR(100),
phone_no INT,
flight_no INT,
flight_name VARCHAR(100),
arrival_date DATE,
departure_date DATE,
PRIMARY KEY (passenger_id),
FOREIGN KEY (flight_no) REFERENCES travel(flight_no)
);

-- Insert data into the passenger table
INSERT INTO passenger (passenger_id, passenger_name, phone_no, flight_no, flight_name, arrival_date, departure_date)
VALUES
('P001', 'John Doe', 1234567890, 101, 'Flight 101', '2023-11-10', '2023-11-15'),
('P002', 'Jane Smith', 9876543210, 102, 'Flight 102', '2023-11-12', '2023-11-18'),
('P003', 'Bob Johnson', 5551234567, 103, 'Flight 103', '2023-11-15', '2023-11-20');

-- Insert data into the travel table
INSERT INTO travel (agent_name, agent_id, flight_city, booking_assignment, passenger_id, flight_no)
VALUES
('Travel Agency 1', 'A001', 'City A', 'Booking A', 'P001', 101),
('Travel Agency 2', 'A002', 'City B', 'Booking B', 'P002', 102),
('Travel Agency 3', 'A003', 'City C', 'Booking C', 'P003', 103);

1)
SELECT
t.agent_id,
p.passenger_id,
p.passenger_name,
p.phone_no,
t.flight_city,
t.booking_assignment,
p.arrival_date,
p.departure_date
FROM
travel t
JOIN
passenger p ON t.passenger_id = p.passenger_id;
2)
SELECT
t.agent_id,
t.agent_name as travel_agency,
p.passenger_id,
p.passenger_name,
p.phone_no,
t.flight_city,
t.booking_assignment,
p.arrival_date,
p.departure_date
FROM
travel t
JOIN
passenger p ON t.passenger_id = p.passenger_id;
3)SELECT
t.agent_id,
t.flight_no,
AVG(COUNT(t.passenger_id)) AS avg_bookings
FROM
travel t
GROUP BY
t.agent_id, t.flight_no;
4)SELECT
p.passenger_id,
p.passenger_name,
p.phone_no,
t.agent_id,
t.agent_name,
t.flight_city,
t.booking_assignment,
t.flight_no,
p.arrival_date,
p.departure_date
FROM
passenger p
JOIN
travel t ON p.passenger_id = t.passenger_id;
5)SELECT
p.passenger_id,
p.passenger_name,
p.phone_no,
t.agent_id,
t.agent_name,
t.flight_city,
t.booking_assignment,
t.flight_no,
p.arrival_date,
p.departure_date
FROM
passenger p
JOIN
travel t ON p.passenger_id = t.passenger_id
WHERE
p.flight_city = t.flight_city
AND p.arrival_date = t.arrival_date;
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.