average

What's the most efficient way to get the horizontal average in a MySQL query?

I have the following MySQL-table Id | One | Two | Three ---------------------------- 1 | 10 | 30 | 20 2 | 50 | 60 | 20 3 | 60 | NULL | 40 Edit: Of course the table doesn't need to be NULL by default, but I don't want it to affect the average (so the average is calculated as 50 and not 33,33). I want tha...

C++ STL List calculate average

I have to correct some C++/STL code. Unfortunately I have very little C++ experience and know nothing about STL. Nevertheless I finished most of it, but the function below is still giving me problems: C++ source: double MyClass::CalculateAvg(const std::list<double> &list) { double avg = 0; std::list<int>::iterator it; for(i...

SQL finding the maximum of all averaged results

I have the relation instructor(ID, name, dept_name, salary). How would I go about finding the name of the department with the highest average salary? ...

Mysql Average on time column?

Hi i have this query: SELECT avg( duration ) as average FROM `login`; The datatype for duration is "time", thus my value is like: 00:00:14, 00:20:23 etc I execute the query it gives me: 2725.78947368421 What is that? I want in time format, can mysql do the average on time?? ...

MySQL sort by average of two averages

I am working on a contest site where there are two types of users, normal site members, and judges. Each can use a drag and drop tool to order the entries in a particular contest in the order they choose. When they are done the relevant entry ids are attached a ranking value that can then be used to determine which entry in contest got t...

Find average date from collection of dates (Ruby)

Hey guys, I have a table of guesses, within each guess is just a date. I was wondering how I would go about turning two or more dates into an average. <div id="logic"> <% foo = Date.today %> <% bar = Date.today + 10 %> <%= (foo + bar) / 2 %> Something like this, but obviously Ruby wont let me divide the two dates, any help much appr...

MS-SQL Average Columns with NULL

So I've got 3 different columns (basket 1, 2, and 3). Sometimes these columns have all the information and sometimes one or two of them are null. I have another column that I'm going to average these values into and save. Is there a sleek/easy way to get the average of these three columns even if one of them is null? Or do I have to hav...

Calculate average date difference between records in MS Access

I have a list on when items have been handed out. The table has the following structure: primary key - autonumber itemname itemid - number datehandedout - date/time I want to calculate the average length of time between when one object is given out and the next one is given out. There will be a number of different items for which the...

Real average filesize in a set of files...

Hi, I have an apparently "simple" problem but I can't find the solution for some reason... I have n millions files of different sizes and I want to find the average filesize. To simplify it, I grouped them in multiples of 16KB. < 16 KB = 18689546 files < 32 KB = 1365713 files < 48 KB = 1168186 files ... Of course, the simpl...

Calculating the average

This is a related question to one I posted earlier... I'm trying to sum all the input elements that begin with 'pull' and place that total in the 'totalpull' input field. I have that part working. Now, I'm trying to calculate the average if a user enters something manually in the 'totalpull' input field and set each 'pull' input to tha...

Calculating moving average/stdev in SAS?

Hye guys, I included a screenshot to help clarify my problem: http://i40.tinypic.com/mcrnmv.jpg. I'm trying to calculate some kind of moving average and moving standard deviation. The thing is I want to calculate the coefficients of variation (stdev/avg) for the actual value. Normally this is done by calculating the stdev and avg for ...

R: What are the best functions to deal with concatenating and averaging values in a data.frame?

I have a data.frame from this code: my_df = data.frame("read_time" = c("2010-02-15", "2010-02-15", "2010-02-16", "2010-02-16", "2010-02-16", "2010-02-17"), "OD" = c(0.1, 0.2, 0.1, 0.2, 0.4, 0.5) ) which produces this: > my_df r...

Timer\Counter in C for rate calculation?

Need a running (moving, rolling) average algorithm to calculate the 5-minute average bits that are passed in. All I have to work with is an accumulative value for the bits that are passed in. For example: I start with 0 bits, 5 minutes later, I have 10 bits, so my average is 10 bits. 5 minutes later, I have 15 bits, so now my averag...

Calculating multiple column average in SQLite3

I need to average some values in a row-wise fashion, rather than a column-wise fashion. (If I were doing a column-wise average, I could just use avg()). My specific application of this requires me ignore NULLs in averaging. It's pretty straightforward logic, but seems awfully difficult to do in SQL. Is there an elegant way of doing m...

Getting average value from matlab plot?

Hey, I have a simple plot which feature a lot of data points, when i have have graph. Is there a way that i can simple click on all these point and allow matlab to give me a average value of them? Thank you ...

calculate the average of three encrypted numbers

Is possible to calculate average of three encrypted integer? No constrain on the method of encrypting. The point of this is just to hide the three numbers and find average. ...

Calculating average (AVG) and grouping by week on large data set takes too long

I'm getting average prices by week on 7 million rows, it's taking around 30 seconds to get the job done. This is the simple query: SELECT AVG(price) as price, yearWEEK(FROM_UNIXTIME(timelog)) as week from pricehistory where timelog > $range and product_id = $id GROUP BY week The only week that actually gets data changed and is worth ...

Access to iTunes Sound Check Results on iPhone

I would like to propose to the user some songs whose volume doesn't exceed a certain level. Is there any way to access to the results of the 'Sound Check' option, from the iPhone ? If not, do you know if I can calculate that with the audio tools in the iPhone SDK ? Thanks a lot. ...

MySQL: Is it possible to compute MAX( AVG (field) )?

My current query reads: SELECT entry_id, user_id, cat_id, AVG( rating ) as avg_rate FROM `entry_rate` WHERE 1 GROUP BY entry_id cat_id relates to different categories: 1, 2, 3 or 4 Is there a way I can find the maximum average for each user in each category without setting up an additional table? The return could potentially be 4 max...

need more complex index !

I'm sorry if it's not an appropriate question for this site, and if it's necesary I'll close this question. But maybe someone could give me an ideea: I'm trying to find a more complex index to make an hierarchy. For example: 5 votes from 6 = 83% AND 500 votes from 600 = 83%; 10 votes from 600 = 1.66% If I make a hierarchy with the ...