473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 1509
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Fred | last post by:
Hi all, I have done a lot of experimentations using several "or" predicates within an sql select statements on mysql. My only conclusion so far is that whatever syntax or order I use it is...
31
by: mark | last post by:
Hello- i am trying to make the function addbitwise more efficient. the code below takes an array of binary numbers (of size 5) and performs bitwise addition. it looks ugly and it is not elegant...
2
by: Clint Olsen | last post by:
Hello: I posted a thread on comp.programming awhile back asking about an algorithm I implemented on square root. The idea was to use the square root of a prime number as a convenient way to get...
8
by: Daisy | last post by:
Hi Folks, Got a load of business objects - Product, Price, Offer, FAQ, Description... Product contains collections of the others (eg. Product.Offers is a collection of Offer objects) ...
4
by: cd~ | last post by:
How is the efficiency of this statement compared to the efficiency of writing this out in long form? (xml = new XmlDocument()).LoadXml("<dom />") Is there a perfomance gain to single line...
335
by: extrudedaluminiu | last post by:
Hi, Is there any group in the manner of the C++ Boost group that works on the evolution of the C language? Or is there any group that performs an equivalent function? Thanks, -vs
83
by: Licheng Fang | last post by:
Hi, I'm learning STL and I wrote some simple code to compare the efficiency of python and STL. //C++ #include <iostream> #include <string> #include <vector> #include <set> #include...
2
by: yicong | last post by:
I want to select one field from a table,but it should on some conditions which refer to 5 table ,such as A.FILED1=B.FIELD1 AND B.FIELD2=C.FIELD3 AND .... Should I use case "select sum(a.amount)...
19
by: vamshi | last post by:
Hi all, This is a question about the efficiency of the code. a :- int i; for( i = 0; i < 20; i++ ) printf("%d",i); b:- int i = 10;
24
by: David | last post by:
Hi list. What strategies do you use to ensure correctness of new code? Specifically, if you've just written 100 new lines of Python code, then: 1) How do you test the new code? 2) How do...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.