Appendix D. Bonus Exercises
The exercises in this appendix are bonus exercises that are specific to SQL Server. This appendix provides an explanation or question and then provides sample Microsoft SQL Server-based SQL code to execute. Remember that the SQL code can vary from implementation to implementation; therefore, some of these statements need to be adjusted depending on the system you work on. Study the question, code, and results carefully to improve your knowledge of SQL.
1. Determine the aircraft that is used the most.
SELECT TOP 1 A.AIRCRAFTTYPE, COUNT(*) AS TIMESUSED FROM AIRCRAFT A INNER JOIN AIRCRAFTFLEET AF ON A.AIRCRAFTCODE = AF.AIRCRAFTCODE INNER JOIN FLIGHTS F ON AF.AIRCRAFTFLEETID = F.AIRCRAFTFLEETID ...