Query Fetching Average
I have 2 tables in a database. One table consists of persons. Each person appears only once in the table.....
View Complete Forum Thread with Replies
Related Forum Messages:
Average Query With 2 Rows From Same Table
My table: "answer" answerID answer(int) questionID(int) userID(int) answer1 is questionID = 1 answer2 is questionID = 2 WHERE userID is the same for both answer1 and answer2 I want the average of answer1/answer2: AVG(ans1/ans2), but how?
View Replies !
Average Query Execute Time???
I have a query taking about 4 sec that gets only 18 records.. That's not good. What can I do to speen up my Query? <CFQUERY DATASOURCE="#datasource#" NAME="qry_job_search"> SELECT DISTINCT (t1.JobPostId), t1.Actionlkp, t1.Date, tbl_job_posting.*, tbl_job_post_requirements.*, tbl_employer_info.*, tbl_employer_url.*, tblkp_employment_type.*, tblkp_education_exp_lvl.*, tblkp_salary_range.*, tblkp_employment_exp_lvl.*, tbl_job_post_location.*, tbl_job_post_job_categories.JobCat, tblkp_countries.*, tblkp_prefectures.* FROM tbl_job_post_history AS t1 JOIN tbl_job_post_location ON tbl_job_post_location.JobPostID = t1.JobPostID JOIN tblkp_countries ON tbl_job_post_location.CC1 = tblkp_countries.CC1 JOIN tblkp_prefectures ON tbl_job_post_location.CC1 = tblkp_prefectures.CC1 AND tbl_job_post_location.PrefectureID = tblkp_prefectures.ADM1 LEFT JOIN tbl_job_post_requirements ON tbl_job_post_requirements.JobPostID = t1.JobPostID LEFT OUTER JOIN tbl_job_post_job_categories ON tbl_job_post_job_categories.JobPostID = t1.JobPostID JOIN tbl_job_posting ON tbl_job_posting.JobPostID = t1.JobPostID JOIN tbl_employer_info ON tbl_employer_info.UserID = tbl_job_posting.UserID LEFT JOIN tbl_employer_url ON tbl_employer_url.EmployerID = tbl_employer_info.EmployerID JOIN tblkp_employment_type ON tblkp_employment_type.ID = tbl_job_posting.EmploymentType JOIN tblkp_education_exp_lvl ON tblkp_education_exp_lvl.ID = tbl_job_posting.EducationExpType JOIN tblkp_salary_range ON tblkp_salary_range.ID = tbl_job_posting.Salarylkp JOIN tblkp_employment_exp_lvl ON tblkp_employment_exp_lvl.ID = tbl_job_posting.EmploymentExpType WHERE t1.JobPostId NOT IN ( SELECT DISTINCT (JobPostId) FROM tbl_job_post_history WHERE Actionlkp =4 AND date = ( SELECT MAX( date ) FROM tbl_job_post_history WHERE JobPostId = t1.JobPostId ) AND JobPostID = t1.JobPostID ) AND HistID = ( SELECT MAX( HistID ) FROM tbl_job_post_history WHERE JobPostID = t1.JobPostId AND Actionlkp =1 ) AND Date >= ( curdate( ) - INTERVAL 30 DAY ) <CFIF SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A EQ 0 AND SESSION.CITY_A EQ ""> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' <CFELSEIF (SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A NEQ 0 AND SESSION.CITY_A EQ "") OR FORM.PREFECTURE NEQ 0> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' AND tbl_job_post_location.PrefectureID = '#SESSION.PREFECTURE_A#' <CFELSEIF SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A NEQ 0 AND SESSION.CITY_A NEQ ""> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' AND tbl_job_post_location.PrefectureID = '#SESSION.PREFECTURE_A#' AND tbl_job_post_location.PostCity LIKE '%#SESSION.CITY_A#%' </CFIF> <CFIF (SESSION.CATEGORY_A NEQ 1) OR FORM.CATEGORY NEQ ""> AND tbl_job_post_job_categories.JobCat = '#SESSION.CATEGORY_A#' </CFIF> <CFIF (SESSION.KEYWORD NEQ "") OR FORM.KEYWORD NEQ ""> AND t1.Actionlkp = 1 AND (tbl_job_posting.JobTitle LIKE '%#session.Keyword#%' OR tbl_job_posting.JobDescription LIKE '%#session.Keyword#%' OR tbl_job_post_requirements.JobRequirements LIKE '%#session.Keyword#%') <CFIF SESSION.KEYWORD NEQ "" AND SESSION.PGV NEQ "brief"> <CFSET SESSION.PGV = "detailed"> </CFIF> </CFIF> <CFIF SESSION.EMP_TYPE_A NEQ 1> AND tbl_job_posting.EmploymentType = '#SESSION.EMP_TYPE_A#' </CFIF> <CFIF SESSION.EXP_LVL_A NEQ 1> AND tbl_job_posting.EmploymentExpType = '#SESSION.EXP_LVL_A#' </CFIF> <CFIF session.SRT EQ "D"> ORDER BY Date DESC <CFELSEIF session.SRT EQ "C"> ORDER BY tbl_employer_info.CompanyName <CFELSEIF session.SRT EQ "L"> <CFIF form.country NEQ 0> <CFIF form.prefecture NEQ 0> <CFIF form.city NEQ 0> ORDER BY tbl_job_post_location.PostCity </CFIF> <CFELSE> ORDER BY tblkp_prefectures.FullNameS, tbl_job_post_location.PostCity </CFIF> <CFELSE> ORDER BY tblkp_countries.CC1, tblkp_prefectures.FullNameS, tbl_job_post_location.PostCity </CFIF> <CFELSEIF session.SRT EQ "T"> ORDER BY tbl_job_posting.JobTitle </CFIF> </CFQUERY> Can anybody see a shortcut to get the same results??
View Replies !
Fetching One Field
let's say i have a table in my database, with only one column. all i want to do is retrieve a list of the entries.. i could do it like this $result = mysql_query("SELECT * FROM t1"); while( $x = mysql_fetch_row($result) ) { echo $x[0]; } but it seems kinda silly to fetch an entire array, when only the first index is used. is there a better/more efficient way?
View Replies !
Numbering And Fetching
Well I thought I read somewhere it was possible to fetch a row, and get the number of something in one query.For instance I have a member table, and it has a column for userid, I would like to number the amount of posts they have made in the newspost column, which is identified by posterid. So "SELECT members.userid FROM members WHERE num(members.userid=newspost.posterid) AS newscount" Something like that... is it possible to do in 1 query? I know theres some num function that can be used inside the query...
View Replies !
Fetching Data
An options table: tbl_options option_id option_name option_value And a linking table that links the options, to the products table: tbl_option_links ol_id ol_productid ol_size ol_weight This is example data in tbl_options option_id = 1 option_name = size option_value = small option_id = 2 option_name = size option_value = medium option_id = 3 option_name = weight option_value = 1kg option_id = 4 option_name = weight option_value = 5kg This is example data in tbl_option_links ol_id = 1 ol_productid = 1 ol_size = 2 'references option_id ol_weight = 4 'references option_id e.g, The result set i'm after is: ol_id = 1 ol_productid = 1 ol_size = 2 ol_sizevalue = medium ol_weight = 4 'references option_id ol_weightvalue = 5kg
View Replies !
Fetching Information
an example: $dbl->query($query); $res = $dbl->get_result(); how do i pull information from a row in $res without automatically moving the pointer ahead.with: $myrow = $res->fetch_array() i pull the correct information but i don't want the pointer to move ahead in $res.
View Replies !
Fetching Auto-increment
I am writing to a table with a cell that is at auto-increment and need the auto-incremented value as feedback from the writing to the table process. e.g. table abc field a (= auto increment) field b field c my SQL query INSERT INTO table_abc (b,c) VALUES ('5','9') Now the value in cell a would be at auto-increment but I would need to know which value it would have been set when I inserted the values above for b and c
View Replies !
Fetching First 3 Then Subsequent 3 Rows
I have my sql database with news in, and i want to print the first few news storys in big sorted by date, and then have links underneath to the next few, but not printed in full. should i fetch twice with 'ORDER BY date DESC LIMIT 3' then the second time skip the first 3 rows? if so how do i 'skip' the first 3.... or is there a more elegant solution?
View Replies !
Fetching Text From Phrase
i can fetch tousearray content from following table using following query PHP Code: SELECT `title` , `message` , `touserarray` FROM `pmtext` WHERE `fromusername` = 'zodehala' ; but how can i fetch only joe word from tousearray column ?
View Replies !
Updating Rows While Fetching?
I'm trying to be able to do somthing here, my problem is figuring out a way to check through every row in a table, and write the timestamp date value that results in my set of if statements in a specific field of the row that I'm checking. Here's the code that I've written so far, and it's not working... Any suggestions? <?php $db->query("SELECT * FROM gtraining WHERE start_date<NOW() AND end_date>NOW()"); while($db->fetch()) { $thisid = $db->row['id']; if ($db->row['date1'] > date('YmHis')) { $nextdate = $db->row['date1']; } else if ($db->row['date2'] > date('YmHis')) { $nextdate = $db->row['date2']; } else if ($db->row['date3'] > date('YmHis')) { $nextdate = $db->row['date3']; } else if ($db->row['date4'] > date('YmHis')) { $nextdate = $db->row['date4']; } $query = "UPDATE gtraining SET next_date='$nextdate' WHERE id=$thisid"; } ?>
View Replies !
Fetching And Posting Info
I am having some issues using the mysql_numrows function and I am getting this error Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource I have also tried mysql_fetch_row and some otehr functions but get this warning pertaining to it. Is this a server problem? Does my server not hold these resources. It is PHP enabled, and MYSQL.
View Replies !
Fetching Non-existent Rows
I've got a table "banneractivity", which stores clicks and views of banners on my website. The table contains the following fields: id INT activitydate DATE activitytime TIME action (either "click" or "view") bannerid INT I want to retrieve the activity by the hour, to show in some statistics. I've used the following query thus far: SELECT id, COUNT('action') AS actionsum, HOUR(activitytime) as theHour FROM banneractivity GROUP BY theHour This works reasonably well, but I would like to retrieve 24 rows, for every hour of the day, even if there has been no activity in a particular hour. Is this possible? Another thing I would like; is there a way to distinguish between "click" and "view" and therefore select two different sums from the database?
View Replies !
Fetching The POSITION Of A Record
I have this script which allows for users to add other users to be apart of a favorites list. The script works, but when I a user adds another user, I don't know the exact position it ends up in within the records. When a user adds another user as his or her favorite list, the page redirects to the users' favorite list which contains the updated favorite records (the new user has been put in). The results are split up by 20s in their pages. So 50 = 20 + 20 + 10 = 3 pages. Obviously this depends on the ordering of the records. But if I only allow for ordering by user_id, then is there a way to find the position of newly added record? So my query looks like this: SELECT f.user_id,username FROM favorites f INNER JOIN users u USING(user_id) WHERE f.owner_id=[USER_ID of the user who owns the favorite list] ORDER BY user_id LIMIT 20; Then the LIMIT is changed according to what page it's on. But when the new user is added, the user_id can be anywhere in between the other favorite records. It can be on page 1,2,3,etc... So what I want to happen is that when the user adds someone else, I want the script to find the position of where exactly the record has been added. PHP $pos_sql = mysql_query('SELECT...POSITION OF USER_ID WHERE THE OWNER_ID OF THE FAVORITE LIST IS THIS'); //Finds the record number position of the newly added user$pos_row = mysql_fetch_row($pos_sql);$pos = $pos_row[0];$limit = 20; //20 results per page//The page is now found$page = ceil($pos/$limit);//now select the 20 records from the page where the newly added favorite record consists. The favorites table only contains two columns: owner_id and user_id. I don't want to add anything new, such as a date column, because I don't really need it. One other solution would be to simply fetch every record from the table which are linked to the owner and order by user_id and make a loop that increments a php variable to see where the position on the newly added favorite is.
View Replies !
Database Fetching Gives Warning
I am using the following code to extract info from db and display it. The extracted info is basically a link to a stored image. I get the following warning after $sql data is printed as shown SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT 8, 1 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mysite/public_html/addons/class.upload/pages.php on line 66 PHP $sql = "SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT $from, $max_results"; mysql_query($sql); echo $sql; while($row = mysql_fetch_array($sql)) { if(strlen(isset($_GET['tcheck']))>0 && $_GET['tcheck']==$safeurl->make_safe_url($row['title'])){ $tcheck=trim(mysql_real_escape_string($_GET['tcheck'])); }else{ echo "invalid query"; exit;} echo "<!--start-->"; echo "<font size=3><b>"; echo $row['title']."</b><br /></font>"; echo "<font size=2>"; echo "Added On "; echo date("jS F Y H:i:s", $row['date'])."<p>"; echo '<img src="/addons/class.upload/test/'.$name.'" border="0" height="50%" width="50%" alt="' . $row['title'] .'" />' echo "<!--end-->"; }
View Replies !
Fetching MySQL Stored Procedure
Can anyone confirm it's not yet possible to retrieve the result set from a stored procedure in MySQL5? I found some posts regarding this issue but no answers yet. I'd like to keep data-model specific stuff out of my Perl DBI code...
View Replies !
Fetching Highest Column Value, From A Table...
To simplify things, lets say l've got a table, with three columns... an auto-increment ID, the user's name, and their age (which is an integer). lets say my column has five rows: TABLE NAME: my_users column 1 | column 2 | column 3 [ID] [NAME] [AGE] ------------------------------ 0 | Bill | 23 1 | Bob | 18 2 | Eric | 37 3 | Steve | 58 4 | Frank | 19 ------------------------------- Now, lets say l wanted to tell the user who the oldest user in table was, with something like: Hello, our oldest user is $oldest_age and our youngest user is $youngest_age $sql = 'SELECT age FROM `my_users` WHERE ... ???? obviously Steve is the oldest as he's 58, and Bob is the youngest at 18... However l was wondering what the most efficient way to select this data quickly from the database would be? Though this example is small, l've got 10,000 rows in the actual application l working with here, so a while loop won't really cut it
View Replies !
Noob Issue With Cursor, Only Fetching 1 Row Of Data ;)
I have recently started using stored procedures in our application, and today, I have tried to create a cursor to fetch me some data, but for some reason it only fetches 1 row of data. Its a really simple cursor (and procedure) at the moment, so im really stumpped. DELIMITER $$ DROP PROCEDURE IF EXISTS `test`.`task_get_task_list` $$ CREATE PROCEDURE `test`.`task_get_task_list` () BEGIN DECLARE field_value VARCHAR(20); DECLARE value_value VARCHAR(255); DECLARE task_user_filter_cursor CURSOR FOR SELECT field , value FROM task_user_filter_settings; OPEN task_user_filter_cursor; REPEAT FETCH task_user_filter_cursor INTO field_value , value_value; IF NOT done THEN SELECT field_value , value_value; END IF; UNTIL done END REPEAT; CLOSE task_user_filter_cursor; END $$ DELIMITER ; The table looks like this (well here are some SQL statments to create the table and add some dummy data) CREATE TABLE `task_user_filter_settings` ( `task_user_filter_settings_id` int(10) unsigned NOT NULL auto_increment, `task_user_id` int(10) unsigned NOT NULL, `field` enum('pro','sub_pro','prior','cat','dead','status','assig_user','assig_group','dep') collate latin1_general_ci default 'assig_user', `value` varchar(255) collate latin1_general_ci default NULL, PRIMARY KEY (`task_user_filter_settings_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ; INSERT INTO `task_user_filter_settings` VALUES (1, 1, 'assig_user', Ƈ'); INSERT INTO `task_user_filter_settings` VALUES (2, 2, 'cat', Ɖ'); INSERT INTO `task_user_filter_settings` VALUES (3, 1, 'prior', Ƌ');
View Replies !
7 Day Average
I don't know if this can be done but I'm looking to write a query that selects the LAST 7 records the and gives me an AVERAGE. Basically I have a table which logs the number of hits each day, I want to select the last 7 and see what my average is. How do i write something like this? there is is only 2 fields in the counter table called date and counter.
View Replies !
Average Age
I have a dating script running which uses MySQL to store the users and their information. Now that I have some users, I would like to create a PHP file to show some site statistics. Actually I would like to get the average age of the users that are stored in the database, for example something like Average age: (At this point I would just like the average age, for example 27.33) Is this possible in some way?
View Replies !
Best Average
OK. Bit of a maths question (at which I am useless) Basically i've got a table with avg_rating and users. avg_rating is the average rating of a specific id and users is that amount of people who have voted. I'm trying to sort the list by the best rating. However, if 50 users have voted an average of 2 for one id but only one user has voted 5 for another id, this id would be 1st on the list. Is there a way I can sort the table by the best avg compared to the total of users that have voted?
View Replies !
Running Average
How can I get mysql to do a running average of a given field using dates from another column so that the average for each element is for a given time period rather than from the 5 rows next to the element?
View Replies !
Average Between Two Dates
I am trying to figure out how to find the avg in between two dates in the work_date field. For example, let's say I want the avg from 2007-01-24 to 2007-05-06, I would have to find the avg by taking the values in the daily_typing_pages columns and add up all the columns between the the dates provided. (E.G. (100+220+350+250+170)/5).
View Replies !
Calculating Average Age
I got this players table and I do want to list its average age... SELECT AVG(YEAR(SUBDATE(CURDATE(), TO_DAYS(birth)))) FROM players This works fine for me BUT, it doesn't on my server though it isn't 4.1.XX as it is on my computer at home.
View Replies !
Getting Average Of The Count
My table (site_visit) is as follows DATE | SITE 01-01-06 | London 01-12-06 | New York 01-30-06 | Chicago 02-02-06 | Mumbai 02-05-06 | JBerg 02-20-06 | Munich 03-05-06 | New York 03-10-06 | JBerg I am trying to get the average site visits per month so far I can get the count per month using: SELECT count( * ) FROM `site_visit` GROUP BY Date_Format( date, '%m %Y' ) How can I get an average of count(*)? Iam using MySQL 4.0.14 I can use php to do this, but I am trying to minimize the use of PHP.
View Replies !
Average Length
Basiically I have a table called ‘Members’ with the following attributes, (the m is short for member), Members (mno , mname, date_joined, date_left, maddress, mtel) I need to produce a single SQL statement that will output the longest length of current membership, the shortest length of current membership and the average length of current membership.And the out put I get should be easily understood, not just a number if you what i mean.
View Replies !
Calculate Best 3 Average
I am looking for help to calculate an average based on a top 3 score. Potentially there could be up to 10 entries per user & I need to calculate what their best 3 scores are as an average. you also need to bear in mind that there could be duplicate scores, which would need to be excluded. For example user 1 could have entries as below 30, 20, 43, 30, 45, 23, 27, 30, 41, 20 which would give you the best 3 scores average as 38.7. Can anybody out there help me achieve this in a query?
View Replies !
Average From Two Tables ...
I have one table called 'ratings_student' as below: def_user_id | rating_student ________________________________ ____61______|________2_______ ____61______|________3_______ ____62______|________5_______ ____62______|________4_______ ____63______|________2_______ ____63______|________5_______ and the other called 'ratings_teacher' as below: def_user_id | rating_teacher ________________________________ ____61______|________4_______ ____61______|________5_______ ____62______|________1_______ ____62______|________2_______ ____63______|________3_______ ____63______|________5_______ If you could help I need to work out the sql query to get the average rating from BOTH TABLES COMBINED and GROUP BY def_user_id I have a good idea of what's required as I am able to do it for individual tables but not both table ratings combined...
View Replies !
Returning A One Value Average
I'm using PHP and MySQL, and am trying to return an average (songle value). My code isn't working, and I'm getting confused between the mysql_fetch, here's my code: $average = "SELECT AVG(overall) as overall, AVG(gameplay) as gameplay, AVG(graphics) as graphics, AVG(sound) as sound FROM VIDEO_GAME_DETAIL WHERE name=" .$row['name']; $result = mysql_query($average); $rating = mysql_fetch_array($result); // down in an HTML table echo "<td>" .$rating['overall']. "</td>"; $row['name'] is the name of a PC Game from the VIDEO_GAME table. In the VIDEO_GAME_DETAIL table I have reviews for many games, with ratings. My goal here is to average the different ratings (overall, gameplay, sounds and graphics) for a one game, and stick them with the main page that lists the games (1 row per game). I get this following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /Users/Marconi/Grad/lleccia/www/ISYG250/proj4/reviews.php on line 54 line 54 is $rating = mysql_fetch_array($result);
View Replies !
Average From Two Tables
I've two tables storing the scores of test marks. The following show the selected scores from the two tables of a certain person with id=1 and level=5: # table1 id level score 1 5 80 1 5 80 1 5 100 # table2 id level score 1 5 40 1 5 60 1 5 50 1 5 70 The sum from table1 is 260 and the sum from table2 is 220 for a total of 7 tests. The grand total is 480. I would like to be able to obtain the average of 68.57 (480/7) for a particular person of a particular level. Would I be able to do that with a single SQL? I've tried a number of sql queries but the don't work.
View Replies !
Ordering Average
I'm wondering how should I sort my results. I have the sum of the votes and the number of voters. I'd like to sort my results in a way that the highest average score is the first and lowest is the last. The problem is that if I have one voter that voted 10 on something the average will be 10 and by regular ordering will be first but that wont represent the true results as more voters is not taking any effect here when it should.
View Replies !
Count On 2 Columns And Average
if I have table with columns which include the following two and some sample data: name type fred abc fred abc john def eddy abc fred xyz john def bill abc 3 3 Is it possible to obtain - a total of the distinct names that have a particular type (say abc which is 3 - fred, eddy, bill) and the total of the same type (abc which is 4) - get the average which is tot_type (4) / tot_name (3)
View Replies !
Average Number Of Records
Say I have 10,000 records, each with a UNIX_TIMESTAMP()'d date field, and want to know the average on how many records have been created each a 24 hour period for the past 3 months. How would I go about doing that? I tried the following but receive a group by error: SELECT AVG(COUNT(*)) FROM my_table WHERE date >= TIMESTAMPADD(MONTH,-3,FROM_UNIXTIME(UNIX_TIMESTAMP())) GROUP BY id
View Replies !
Result With The Highest Average
I need to return the result with the highest average which should be calculated by dividing total_value by total_num_votes. How can I do the division in the query to get the result with the highest average: ( total_value / total_num_votes ) I'm guessing it should look something like this: SELECT ( total_value / total_num_votes ) as average FROM ratings ORDER BY average LIMIT 1
View Replies !
Union Of Tables / Average
I have one table called 'ratings_student' as below: def_user_id | rating ________________________________ ____61______|________2_______ ____61______|________3_______ ____62______|________5_______ ____62______|________4_______ ____63______|________2_______ ____63______|________5_______ and the other called 'ratings_teacher' as below: def_user_id | rating ________________________________ ____61______|________4_______ ____61______|________5_______ ____62______|________1_______ ____62______|________2_______ ____63______|________3_______ ____63______|________5_______ If you could help I need to work out the sql query to get the average rating from BOTH TABLES COMBINED and GROUP BY def_user_id I have a good idea of what's required as I am able to do it for individual tables but not both table ratings combined...
View Replies !
Selecting Average Per Month
********************** *PDATE **** Price * ********************** *2008-12-03** 22 * ********************** *2008-12-01** 36 * ********************** *2008-12-09** 54 * ********************** *2008-11-05** 21 * ********************** *2008-11-15** 22 * ********************** ******************** *Month **** AVG * ******************** *December ** 22 * ******************** *November ** 36 * ********************
View Replies !
Date_format :: Average By Week
I have used the following query to try and average by week select date_format(calldate, '%Y-%m-%d 23:59:59'), avg(billsec) from Clovercdr where calldate Between '2006-02-01 00:00:01' and '2006-03-22 23:59:59' and branchname = 'Boksburg' and billsec > 0 and Network = 'SAMobile' GROUP BY date_format(calldate, '%x%v') I know that it should be averageing every week on monday: 1. is there any way I can average every week from the first day ie. first day is 2006-02-01 which is a wendsday, every wendsday for the given time period 2. I dont understand my results here ....
View Replies !
High Average Load (50%)
I have a Windows 2003 server with MySQL 5 installed (5.0.19). The server has a 3ghz processor and 2gb of memory. The server has about 20 databases of the type MyISAM and there is almost no load trough queries. The mysqld-nt.exe process has an average load of 50% and goes up when a query comes in. Why is this? I have tried logging to see what MySQL is doing but I cannot find anything abnormal.
View Replies !
Average Time Difference
I have a table which includes two timestamps - creationTS and processedTS. I want to run a query that tells me the average difference between these two timestamps on a minute by minute basis, i.e. one row for each minute of the day, containing the total messages created in that minute and average amount of time it took to process data created in that minute. Is this possible in a query, or do I need to grab each entry and use PHP to work out the average processing time?
View Replies !
How Many Is Too Many Queries On The Average Web Page?
I'm just curious... I'm trying to watch how many queries I run in any given page. But I find myself being too conservative sometimes, trying to think of better ways to do things... but then end up getting frustrated. Just looking for some average feedback. In your opinion or experience, how many queries to the DB using PHP is too many queries? I know less is better... i'm just trying to get an idea.
View Replies !
Average, ROUND, COUNT
I'm trying to build my first dynamic web page using PHP & MySQL. I have a fuel economy page that I'm trying to improve by using a DB. I've cobbled the following code together and I'm having partial success but still learning how to use PHP & MySQL. The code below is on this page (www dot njdot dot us/buell/ulydata2.php) and I plan on using a form to add data. Sorry about the link but it would not let me post a real link Part of the trouble I'm having is that the arithmetic is not correct and I'm not familiar enough with PHP/SQL to know how to change it to get the query I'm looking for. What I'm trying to place in the table is the average miles per gallon for each user along with model year and the number of samples in the DB for that user. If someone has the time to review this and offer some suggestions that would be great! PHP Code: ....
View Replies !
Average Of Top Results For Each Country
Tables are; users: ------ uid country (two letter acronym) teams: ------- uid score Average score for each country (top 150 countries, more than 50 users per country minimum): Code: SELECT COUNT(u.country) AS players , u.country , AVG(t.score) AS avg_score FROM users AS u LEFT OUTER JOIN teams AS t ON u.uid = t.uid GROUP BY u.country HAVING players > 50 ORDER BY avg_score DESC LIMIT 150
View Replies !
MySQL Order By Average Of Two Fields
I have made a Toplist mod for vBulletin, and it currently has a setting to choose to rank the sites by their in hits, or their out hits. I would like to add another setting that can rank them by the average of the in and out hits for each of the sites in the Toplist. Does anyone know how I can have MySQL order them by the average of those two fields?
View Replies !
MySQL Round And Average Functions
I have a column in a mySQL database table that stores a rating from 1 to 5. I wish to select all rows from this table and get the average rating rounded to the nearest whole number. I imagine its something like this "SELECT ROUND(AVG(rating)) from ScoreTable"
View Replies !
|