Create SQL queries to accomplish the following tasks using the fly for less database
-
Select all the records from the price table.
-
Select just the names of all the cities
-
Select the IATA code and details of all the terminals
Write queries to accomplish the following tasks:
-
Select the first and last names of all the customer born since Jan 1st,2000
-
Select the discount a type 2 passenger will receive when booking a reservation 19 days in advance
Write Select statements to do the following:
-
Select the names of all the airports in New York
-
Select a list of all flights shwoing the flight number & name(rather than code) of their departure and arrival airport
-
Select a list of all the airports in London and the number of any flights leaving from each one.
Write two SQL statements to perform the following updates to the fly four less database
-
Customer 3607 has got married,update her last name to Samuells.
-
Decrease the number of seats on all flights by 1 to make room for undercover Security
Deleting the following records from the fly four less database
-
Delete the records of all customers over the age of 80,our insurance policy does not allow us to carry them.
-
Delete all reservations for flights 375 on April 7th 2006,The Captain is going on holiday
Write a select statement that returns the names of all cities in alphabetical order
Answer the following questions,provide the queries to prove your answers
-
What is the average age of all the customers
-
Which city has the most airports
-
Where does the longest flight go
-
How many flights leave London on a Tuesday
Here are a few exercises that will really exrecise your SQL skills.
-
Develop an SQL statement that returns the name of the airport with the most flights departing from it.Only return one row and one column data
-
In case of emergency pilots need to know nearby airports that they could divert to.Write a query that returnd a list of all flight numbers,their intended destination an other airports in the same city that thay could land at if required.
-
Develop a report that shows all the cities that the airline doen not currently fly to along with their country codes
Develop quries to accomplish the following tasks:
-
Return a list of all flights along with their un-discount price
-
Display the name of the arrival airport of all flights,format the name so that the names are in lower case except for the first letter of each word
-
Display a list of all customers under 10 that have a birthday in the next week
Scalar Functions are functions that can be used to perform operations on strings,dates,numbers etc.
Unlike aggregate functions they are called for each row of data rather than acting on agroup or all rows
You can use these functions to affect the output or in the where clause to affect what data is returned
select reverse(name)
from airports a inner join flight_profiles f
on a.iata_code = f.dep_apt
where length(name)>10
order by substring(name,4,1)
This example uses some simple functions to return the name of the departure airports that have more than ten characters reversed and ordered by the fourth character.You can even use functions to affect the data used in joins
Scalar functions are the biggest area of difference between different databases and most do not form part of ANSI Standard SQL