By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,883 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,883 IT Pros & Developers. It's quick & easy.

VERY URGENT question about calculating average

P: 54
presently there is a table which records information about users enquiring for fares to a particular destination.

in the existing report which is a php file when a particular date is selected this php file will display the total number of enquiries for each destination and its price for a particular dates. in this php file a select query is executed along with GROUP BY and ORDER BY

ex=
DESTINATION PRICE
sydney 1000
melbourne 2500
perth 2000
sydney 2000
sydney 3000

my question is

1.
i would like to add all sydney fares and find the average and similarly for other cities. ex=

DESTINATION PRICE
sydney 500
melbourne 200

2.
i would like to display the city which had the maximum number of enquiries to the city with minimum enquiries in a descending order with the numeric value.

please provide the code for 1 and 2.

thanks in advance.
Dec 12 '07 #1
Share this Question
Share on Google+
2 Replies


nathj
Expert 100+
P: 938
presently there is a table which records information about users enquiring for fares to a particular destination.

in the existing report which is a php file when a particular date is selected this php file will display the total number of enquiries for each destination and its price for a particular dates. in this php file a select query is executed along with GROUP BY and ORDER BY

ex=
DESTINATION PRICE
sydney 1000
melbourne 2500
perth 2000
sydney 2000
sydney 3000

my question is

1.
i would like to add all sydney fares and find the average and similarly for other cities. ex=

DESTINATION PRICE
sydney 500
melbourne 200

2.
i would like to display the city which had the maximum number of enquiries to the city with minimum enquiries in a descending order with the numeric value.

please provide the code for 1 and 2.

thanks in advance.
Hi,

It sounds like the first question can be answered using nested functions in SQL using the average and sum functions you should be able to get what you want.

The sceond issue could be sorted with a count() variable in the query.

I hope that points you in the right direction.

Cheers
nathj
Dec 14 '07 #2

P: 4
Yes using nested database queries and database functions are generally the best. Calculations done in the database can be more efficient than in some languages.

- Shelon Padmore

presently there is a table which records information about users enquiring for fares to a particular destination.

in the existing report which is a php file when a particular date is selected this php file will display the total number of enquiries for each destination and its price for a particular dates. in this php file a select query is executed along with GROUP BY and ORDER BY

ex=
DESTINATION PRICE
sydney 1000
melbourne 2500
perth 2000
sydney 2000
sydney 3000

my question is

1.
i would like to add all sydney fares and find the average and similarly for other cities. ex=

DESTINATION PRICE
sydney 500
melbourne 200

2.
i would like to display the city which had the maximum number of enquiries to the city with minimum enquiries in a descending order with the numeric value.

please provide the code for 1 and 2.

thanks in advance.
Dec 14 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.