473,403 Members | 2,183 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,403 software developers and data experts.

VERY URGENT question about calculating average

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
2 1352
nathj
938 Expert 512MB
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
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

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

Similar topics

5
by: PeterHardy | last post by:
I'm trying to work out an average field on a report that i'm writing and having the problem described below. e.g. if you had 3 weeks of cash which were 0, 2, 4 then a normal average would be...
6
by: Stephen Miller | last post by:
Firstly, sorry for the long post, but I've included a fair bit of sample data. Im doing a comparision of 10yr Bond prices and CPI adjustments, with an 18 week moving average of the CPI. I'm...
3
by: GregM | last post by:
Hi, I'm hoping that someone can point me in the right direction with this. What I would like to do is calculate the average time it takes to load a page. I've been searching the net and reading...
2
by: Wayne Aprato | last post by:
I've read most, if not all, of the posts on moving average and still can't find a simple solution to my problem (if a simple solution exists!) I have a table with 2 fields: Hours and Injuries. I...
5
by: coinjo | last post by:
Problem Statement One of the local banks is gearing up for a big advertising campaign and would like to see how long its customers are waiting for service by teller/service provider at drive-up...
5
by: Mr. Ken | last post by:
I am calculating the phase of an IQ signal, which are polluted by AWGN gaussian noise. Thus, near pi/2, direct division of atan(Q/I) may yield outputs either +pi/2 or -pi/2. How do I handle this...
10
by: Nightspeace | last post by:
Hello Everyone, I am currently trying to create a 3 month running wieghted average to forecast the comming months. My Table consits of 3 colums (Table ID), (Date),(Monthly Total). (Table...
8
by: elias.farah | last post by:
Hello Everyone, I'm having some very weird behavior on a couple of Access forms. (Not all forms, just some of them). The forms have been working for years, under Access XP/2003 etc, and last...
1
by: cmb3587 | last post by:
My code runs fine for the most part...the only time it fails is when I type in a negative to end the array. I don't want the negative number to be included in the array and I thought that is what...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.