471,083 Members | 1,066 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,083 software developers and data experts.

Correctness/efficiency of some sql statements

Hi,

I have the following sql statement written for a Flight center.
Can anyone please help me to find out whether they are correctly written?

Case:
There is a database table named flight that contains the following columns:

Identifier, Date, Time, FlightNumber, SSRCode, Runway, OperationType,
Airline, AircraftType

What SQL statement would you use to obtain:

a) The Number of B737 Aircraft flown each day?
select count(*)
from flight
where Date = day() and Time < time() and FlightNumber = "B737"

b) How many times Qantas departs each day?
select Date, count(*)
from flight
where Airline = "Qantas" and Date = date() and OperationType = "Departure"
order by Airline, Date

c) The daily breakdown of the number of Arrivals and Departures?
select count(*)
from flight
where (OperationType = "Arrival" or OperationType = "Departure")
group by Date, OperationType

Thanks
D
Jul 23 '05 #1
3 1441
>I have the following sql statement written for a Flight center.
Can anyone please help me to find out whether they are correctly written?

Case:
There is a database table named flight that contains the following columns:

Identifier, Date, Time, FlightNumber, SSRCode, Runway, OperationType,
Airline, AircraftType

What SQL statement would you use to obtain:

a) The Number of B737 Aircraft flown each day?
select count(*)
from flight
where Date = day() and Time < time() and FlightNumber = "B737"
I don't pretend to know a lot about airports, but a flight number
is not a type of aircraft on any flight I have ever been on. "flown
each day" would appear to ask for grouping each day's flights so
you could count them, giving a list of days and flights. The current
day and time are irrelevant.

b) How many times Qantas departs each day?
select Date, count(*)
from flight
where Airline = "Qantas" and Date = date() and OperationType = "Departure"
order by Airline, Date
Again, "departs each day" would appear to ask for a list of days
and number of flights on that day. The current date is irrelevant.

c) The daily breakdown of the number of Arrivals and Departures?
select count(*)
from flight
where (OperationType = "Arrival" or OperationType = "Departure")
group by Date, OperationType


Please post the email address of your instructor so posters can
send the correct answer direct.

Gordon L. Burditt
Jul 23 '05 #2
Gordon Burditt wrote:
I have the following sql statement written for a Flight center.
Can anyone please help me to find out whether they are correctly written?

Case:
There is a database table named flight that contains the following columns:

Identifier, Date, Time, FlightNumber, SSRCode, Runway, OperationType,
Airline, AircraftType

What SQL statement would you use to obtain:

a) The Number of B737 Aircraft flown each day?
select count(*)

from flight

where Date = day() and Time < time() and FlightNumber = "B737"

I don't pretend to know a lot about airports, but a flight number
is not a type of aircraft on any flight I have ever been on. "flown
each day" would appear to ask for grouping each day's flights so
you could count them, giving a list of days and flights. The current
day and time are irrelevant.

b) How many times Qantas departs each day?
select Date, count(*)

from flight

where Airline = "Qantas" and Date = date() and OperationType = "Departure"
order by Airline, Date

Again, "departs each day" would appear to ask for a list of days
and number of flights on that day. The current date is irrelevant.

c) The daily breakdown of the number of Arrivals and Departures?
select count(*)

from flight

where (OperationType = "Arrival" or OperationType = "Departure")
group by Date, OperationType

Please post the email address of your instructor so posters can
send the correct answer direct.

Gordon L. Burditt

Hi,, here is the email addr: tf****@yahoo.com.au

d
Jul 23 '05 #3
bsder wrote:
Gordon Burditt wrote:
I have the following sql statement written for a Flight center.
Can anyone please help me to find out whether they are correctly
written?

Case:
There is a database table named flight that contains the following
columns:

Identifier, Date, Time, FlightNumber, SSRCode, Runway, OperationType,
Airline, AircraftType

What SQL statement would you use to obtain:

a) The Number of B737 Aircraft flown each day?
select count(*)


from flight


where Date = day() and Time < time() and FlightNumber = "B737"


I don't pretend to know a lot about airports, but a flight number
is not a type of aircraft on any flight I have ever been on. "flown
each day" would appear to ask for grouping each day's flights so
you could count them, giving a list of days and flights. The current
day and time are irrelevant.
Since I don't exactly know what th FlightNumber look like, if B737 is
not associated with FlightNumber, it might be associate with Identifier?
b) How many times Qantas departs each day?
select Date, count(*)


from flight


where Airline = "Qantas" and Date = date() and OperationType =
"Departure"
order by Airline, Date


Again, "departs each day" would appear to ask for a list of days
and number of flights on that day. The current date is irrelevant.

c) The daily breakdown of the number of Arrivals and Departures?
select count(*)


from flight


where (OperationType = "Arrival" or OperationType = "Departure")
group by Date, OperationType


Please post the email address of your instructor so posters can
send the correct answer direct.

Gordon L. Burditt


Hi,, here is the email addr: tf****@yahoo.com.au

d


Thanks
D
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Daisy | last post: by
4 posts views Thread by cd~ | last post: by
335 posts views Thread by extrudedaluminiu | last post: by
83 posts views Thread by Licheng Fang | last post: by
2 posts views Thread by yicong | last post: by
19 posts views Thread by vamshi | last post: by
24 posts views Thread by David | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.