Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SQL Create a derived attribute to determine a 50% discount for all flights to “P

ID: 3706722 • Letter: S

Question

SQL

Create a derived attribute to determine a 50% discount for all flights to “PVD” (the calculation for the discount is price * .50). List the ticket number, passenger ID, Departing Airport, Depart Date, and Discount Price.

Ticket TicketNum FlightNum DepartDt DepartAirport ArrivalDt ArrivalAirport Price PassengerID 1 1001 8/25/2015 ATL 8/25/2015 ORD $225.00 00001 2 1002 8/27/2015 ATL 8/27/2015 MSY $315.00 00005 3 1003 8/29/2015 ORD 8/30/2015 PVD $275.00 00001 4 1145 9/10/2015 PVD 9/10/2015 ATL $185.00 00002 5 1142 9/17/2015 PVD 9/17/2015 DEN $210.00 00001 6 1146 9/21/2015 PVD 9/22/2015 LAX $455.00 00004 7 2004 10/1/2015 LAX 10/1/2015 ORD $255.00 00001 8 2006 10/15/2015 LAX 10/15/2015 DEN $99.00 00005 9 2009 10/15/2015 LAX 10/15/2015 MCO $300.00 00001 10 2158 10/19/2015 PVD 10/19/2015 BDL $245.00 00004 11 2184 10/23/2015 PVD 10/23/2015 BDL $265.00 00003 12 2130 10/23/2015 ATL 10/24/2015 PVD $185.00 00001 13 2284 10/25/2015 ATL 10/25/2015 ORD $225.00 00002 14 2259 10/27/2015 ORD 10/27/2015 LAX $180.00 00001 15 2298 10/31/2015 ORD 10/31/2015 DEN $205.00 00005 16 2841 10/31/2015 MSY 11/1/2015 BDL $300.00 00003 17 4012 12/9/2015 MSY 12/9/2015 ATL $225.00 00005 18 4011 12/18/2015 BDL 12/18/2015 LAX $300.00 00004 19 4359 12/23/2015 BDL 12/23/2015 ATL $185.00 00003 20 4583 12/30/2015 MCO 12/30/2015 PVD $165.00 00001 21 5923 1/4/2016 MCO 1/4/2016 MSY $200.00 00004 22 5922 1/7/2016 DEN 1/7/2016 LAX $99.00 00002 23 5992 1/29/2016 DEN 1/29/2016 ORD $250.00 00003 24 6000 2/14/2016 DEN 2/14/2016 PVD $199.00 00001 25 6822 2/28/2016 ATL 2/28/2016 PVD $199.00 00002

Explanation / Answer

Answer:

List the ticket number, passenger ID, Departing Airport, Depart Date, and Discount Price.

Query

select TicketNum, PassengerID, DepartAirport, DepartDt, Price * 0.50 as DiscountPrice from Ticket where ArrivalAirport = 'PVD';

Explanation:

The query will select the TicketNum, PassengerID, DepartAirport, DepartDt, and perform the calculation with the field with Price as Price * 0.50 and store it in the field name as DiscountPrice from Ticket by satisfyingthe condition where ArrivalAirport = 'PVD';