Click here to get back home

Correctness/efficiency of some sql statements

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Correctness/efficiency of some sql statements bsder 07-14-2005
Get Chitika Premium
Posted by bsder on July 14, 2005, 3:38 am
Please log in for more thread options
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


Posted by Gordon Burditt on July 14, 2005, 5:13 am
Please log in for more thread options
>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


Posted by bsder on July 14, 2005, 5:25 am
Please log in for more thread options
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_sam@yahoo.com.au

d


Posted by bsder on July 14, 2005, 5:29 am
Please log in for more thread options
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_sam@yahoo.com.au
>
> d

Thanks
D


Similar ThreadsPosted
importing sql statements November 10, 2005, 11:15 pm
Speed comparison of SELECT statements November 22, 2005, 9:57 am
Multiple statements in single query batch October 16, 2005, 1:36 pm
MYSQL Limit on length of insert statements? July 17, 2006, 7:42 pm
MySQL consuming lots of memory during transactions w/ many statements January 30, 2006, 3:30 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap