Question

NOTE: YOU DO NOT NEED TO INSERT MORE DATA INTO THE TABLES. The list of tables available for this assignment is the following

Using the tables provided above, provide SQL statements for the following queries.

i. Display a table of all customers who have purchased tickets for at least 5 flights, excluding any flights that have experi

NOTE: YOU DO NOT NEED TO INSERT MORE DATA INTO THE TABLES. The list of tables available for this assignment is the following MODEL(modellD, economySeats, buisnessSeats, firstClassSeats, cargoCapacity, fuelCapacity, length, wingspan, serviceHours) LOCATION(airportCode, country, address, phone) TICKET ticketNum, luggageLimit, seatNum, classCode, medicalCondition, mealChoice, customerlD, flightID) ROUTE(routelD, description, arriveAirportCode, departAirportCode) IRREGULAR_EVENT(eventNumber,flightlD, eventDate TIme, eventDescription) SERVICE(serviceDate,airfD, description, cost) AIRCRAFT (aicraftlD, mailCargoCapacity, numMedPacks, numDefibritlators, haulType, modellD NEACC MEMBER(memberlD, flightGoldPoints) STAFF(stafflD, name, address, email, phone, passportNum, pilotYesNo, prevHrsPilotExp, attendantYesNo, memberlD) CUSTOMER(customerlD, name, address, country, email, phone, birthdate, passportNum, memberID) FLIGHT flightID, estDepartureDateTime, actDepartDateTime, actArriveDateTime, avgSpeed, avgHeight, estDuration, estFuel, haulType, captainStafflD,firstOfficerStafflD, routelD, aircrafilD) ADDITIONAL_PILOT stafD AightlD, activityCode, activityDesc) HOSTING(staffID, AlightlD) PILOT_QUALIFICATION(qualification, staffID) NOTE: PK is printed underlined and FK is printed in italics.
i. Display a table of all customers who have purchased tickets for at least 5 flights, excluding any flights that have experienced irregular events. Display the customer ID and number of tickets purchased. 15 marks] . For each flight that has already departed, display the flight ID, actual departure date, actual departure time (in a separate column), and the number of days that have passed between now (system date) and the departure. The displayed table should have 4 columns. Display the date in the same format as Ό1st January 2019, and display the time in 12-hour format ending in am' or pm' with hours and minutes shown (but not seconds). I5 marks
0 0
Add a comment Improve this question Transcribed image text
Answer #1

----- I

SELECT customerID,count(ticketNum) As TicketCount FROM Ticket WHERE flightid NOT IN (SELECT flightid from Irregular_event) GROUP BY Customerid HAVING count(DISTINCT flightid)>=5;

in above query we have filtered flight with irregular events using sub query. Group by helps to get count of ticket's and Having helps to filter customers who have not purchased 5 flight ticket's. DISTINCT key word in Having clause helps to different flight I'd.

-------- j

SELECT flightid,

CAST(DAY(actDepartDateTime) AS VARCHAR(2)) + 'st ' + DATENAME(MM, actDepartDateTime) + ' ' + RIGHT(CAST(YEAR(actDepartDateTime) AS VARCHAR(4)), 2) AS DepartDate,

RIGHT(CONVERT(VARCHAR(20), actDepartDateTime, 100),7) AS DepartTime,

DATEDIFF(day,actDepartDateTime,GETDATE()) As NumDays FROM flight WHERE estDepartDateTime < GETDATE();

In SQL server GETDATE helps to get current system time. In Oracle you need to use SYSDATE for current date time

Add a comment
Know the answer?
Add Answer to:
Using the tables provided above, provide SQL statements for the following queries. NOTE: YOU DO NOT NEED TO INSERT MOR...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR...

    NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR FOREIGN etc Customer [ CustID, LastName, FirstName, Address, City, State, Zip, Phone, Fax, Email] Product [ ProdID, Description, Color, Size, Pack] Sales [ TransID, CustID, ProdID, Price, Quantity, Amount] Write SQL statement to produce a list of unique products and their prices from the Sales table. Please ensure that the products do not repeat. Write an SQL statement to list ProdID and Description for...

  • can someone solve these quick please and thank you! sql chapter 4 Query #1: List the...

    can someone solve these quick please and thank you! sql chapter 4 Query #1: List the company name, contact name, contact title and the phone number for customers who HAVE NOT put in an order. Use an outer join. Query #2: Create a listing displaying the employee first name, last name and the full name (First name space Last Name) of the person they report to (Supervisor). This is a self-join. If an employee does not report to anyone then...

  • Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and...

    Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and phones of all swimmers currently in level (of id) 3. +-------+---------+---------------------------+ | FName | LName   | EMail                     | +-------+---------+---------------------------+ | Bobby | Khan    | theBKhan1 | | Clara | Johnson | ClaraJohnson_11 | +-------+---------+---------------------------+ 2 rows in set (0.00 sec) (2) Provide the names of swimmers who have signed up to participate in the event '100M Butterfly' of Meet id 1. +-------+---------+ | FName...

  • Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the p...

    Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...

  • A test specification provides designers with what needs to be known in order to perform a...

    A test specification provides designers with what needs to be known in order to perform a specific test, and to validate and verify the requirement to be tested. The test script is divided into the test script, which is the generic condition to be tested, and one or more test cases within the test script. Provide a test script and test case for at least 3 of your requirements identified in your requirements specification. Provide the following format for an...

  • Hi, I'm trying to do my homework for my SQL Server class I keep getting stuck on the questions 1-...

    Hi, I'm trying to do my homework for my SQL Server class I keep getting stuck on the questions 1-5  I found out like how the format need to be I'm just stuck on implanting the code in. Auntie B's Antic ERD CUSTOMER OWNER PEOPLE PeoplelD CustomerSince CHARITY Peopleld FirstName LastName Address City State Zip Phone CellPhone EMail PeopleType CharityID Name Address City State WORKERS PeoplelD HireDate TermDate SSN ip Phone ContactID ORDERS OrderlD OrderDate CustomerlD EmployeelD DONATION DonationID DonationDate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT