
Drewser33
Members-
Posts
67 -
Joined
-
Last visited
Everything posted by Drewser33
-
The used command is not allowed with this MySQL version
Drewser33 replied to Drewser33's topic in MySQL Help
Yes, VARIABLE NAME - LOCAL_INFILE, VARIABLE_VALUE - ON -
The used command is not allowed with this MySQL version
Drewser33 replied to Drewser33's topic in MySQL Help
I tried doing a chmod 777 on that directory, but the problem still exists. -
Mysql version 5.5 Linux OS - Debian LOAD DATA LOCAL INFILE '/var/tmp/import.csv' INTO TABLE r_data FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 ROWS (first_name,last_name,a_number,a_id) Error: The used command is not allowed with this MySQL version I have tried this from the mysql command line, phpmyadmin, and a php script, all with the same error. I have changed the local_infile GLOBAL VARIABLE to ON and restarted the mysql service to no avail. There are a lot of ideas on this out there, but I can't seem to put it all together. I was able to run the version of LOAD DATA INFILE, if I placed the same CSV in the root mysql directory, so I know that the CSV information is valid. Thanks for any help.
-
What I am trying to do is to submit as POST values to database_write.php, from within the while statement. What is happening is I am getting the second row of data every time I change the primary button. Currently database_write.php is just doing print_r($_POST), And my array is always the same, no matter which select box I choose from. How can I get the values to be associated with the row I am currently changing? Any help would be great, thanks. What I have so far: <table class="table table-bordered table-hover"> <thead> <th>Room Number</th> <th>Primary Caregiver</th> <th>Seconday Caregiver</th> </thead> <tbody class="list"> <?php $sql = 'SELECT alarm_device_id, alarm_description, alarm_device_type, notes FROM alarm_device where notes in (\'MSU\') ORDER BY alarm_description'; $retval = mysql_query( $sql, $con ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } $x=0; while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { $id = $row['alarm_device_id']; $alarm_description = $row['alarm_description']; echo '<form id="msu_form">'; echo "<tr><td>{$row['alarm_description']}</td>"; echo "<td>"; $query2 = "SELECT alert_device_id,alert_description FROM alert_device WHERE notes = 'MSU'"; $result2 = mysql_query($query2) or die("Error in alarm_device select:" . mysql_error()); $count2 = mysql_num_rows($result2); if($count2 > 0) { //echo '<select name='.$x.'>'; echo '<select id="Primary" name="primary" onchange="doAjaxPost(this)">'; while($row2 = mysql_fetch_array($result2)) { echo "<option value=".$row2['alert_device_id'].">".$row2['alert_description']."</option>"; } echo "</select>"; }else { echo "Please update alert device to this area"; } echo "</td>"; echo "<td>"; $query3 = "SELECT alert_device_id,alert_description FROM alert_device WHERE notes = 'MSU2'"; $result3 = mysql_query($query3) or die("Error in alarm_device select:" . mysql_error()); $count3 = mysql_num_rows($result3); if($count3 > 0) { echo '<select id="Secondary" name="secondary">'; while($row3 = mysql_fetch_array($result3)) { echo "<option value=".$row3['alert_device_id'].">".$row3['alert_description']."</option>"; } echo "</select>"; }else { echo "Please update alert device to this area"; } echo "</td>"; $aid = $id + $x; //echo $aid; //$ad = $alarm_description + $x; echo '<input type="hidden" id="ID" name="ID" value="'.$id.'"/>'; //echo '<input type="hidden" id="desc" name="desc" value="'.$ad.'"/>'; //echo '<td>'."<input type='submit' name='btnupdate' value='UPDATE' /></td>"; //echo '<td><input type="button" value="Ajax Request" onClick="doAjaxPost()"></td>'; echo '</form>'; $x = $x+1; } ?> <script> function doAjaxPost() { // get the form values var primary = $('#Primary').val(); var secondary = $('#Secondary').val(); var hidden = $('#ID').val(); //var desc = $(sel).parent().nextAll('#desc').val(); $.ajax({ type: "POST", url: "functions/database_write.php", data: $('#msu_form').serialize(), //data: "Primary="+primary+"&Hidden="+hidden+"&Secondary="+secondary, success: function(resp){ //we have the response alert("'" + resp + "'"); }, error: function(e){ alert('Error: ' + e); } }); } </script> </tr> </tbody> </table>
-
Is there any way to have a field that will update any time its row is updated? My situation is that I will have multiple devices writing to a database, and in one case the time that is being kept track of is important. And the devices writing to the database are a bit difficult to keep accurate times on, so instead of writing the time from the devices themselves, I was hoping I could just have a field update itself. I know it can be done on INSERT, but I do not want to do an INSERT every time. Thanks!
-
echo '<option value='.$row['ID'].'>'.$row['LastName'].', '. $row['FirstName'].'</option>'; This is part of a select box, so no, I did not have the []. I will use a checkbox instead, that will likely be a better type of input instead, and I will use the [] as you mention. Thank you. I will build the checkbox quickly and check it out.
-
I get : string(2) "27"
-
foreach($_POST['customerID'] as $value) Warning: Invalid argument supplied for foreach() I have used _GET as well, to confirm that there are values for this variable. What am I missing? Thanks
-
This should be simple, but I can't seem to get it right. I am using a query to select values, it returns a list of 7 results. I would like to use a foreach for those results. Below is how I understand it (at this point just trying to view the results) but I am getting nothing. I am new to arrays and the foreach. $query = "SELECT a FROM table WHERE b IS NULL"; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_array($result); foreach($row['a'] as $value) { echo $value.'<br>'; } Thanks
-
Is there a reason why IE doesn't just use the word Copy in a URL. It turned it into a copyright symbol? Firefox did not do this. Just wondering if anyone has any idea why.
-
Table fields are DeviceID and GuardID. Existing in this table are a large number of rows with the same GuardID (49) and I would like to run an insert query to insert the same amount of rows with the same DeviceID's that will have a GuardID of 843. This is what what makes sense to us but it is not working. INSERT INTO DeviceGuard SELECT DeviceID FROM DeviceGuard WHERE GuardID = 49 , 843 Thanks
-
Thanks Keith!! That query worked perfect.
-
I am trying to write an update query with a null value. But I continue to get this error: "Incorrect date value: '' for column 'Date_Eng_replied' at row 1" The DB is set to allow Null Values for this field. I have tried defining the variable as Null in a few ways: $replydate = $_GET['replydate']; if($replydate == '') { unset($replydate); } AND $replydate = $_GET['replydate']; if($replydate == '') { $replydate = NULL; } AND $replydate = $_GET['replydate']; if($replydate == '') { $replydate = 'NULL'; } Query if needed $query4 = "UPDATE tblopen_issue_remarks SET Fix = '$fix', Date_Eng_replied = '$replydate', Status = '$status' WHERE ID = '$threadid'"; mysql_query($query4) or die(mysql_error()); None of which will write the Null into the DB
-
Yeah??? I don't understand, if you replace the OR with an AND the query never results in any records matching. I don't see how the OR is what is causing the problem. Could you show the correct query and assist me by explaining why the OR is throwing it off? Thanks
-
-- -- Dumping data for table `tbltickets` -- INSERT INTO `tbltickets` (`ID`, `CustomerNumber`, `Contact`, `ContactPhone`, `Extension`, `TroubleID`, `Summary`, `OpenedBy`, `DateOpened`, `Status`, `DateClosed`, `ClosedBy`, `FollowUp`, `DateFollowUp`, `Type`, `warrantyActivity`) VALUES (11490, '000000', 'test', '', '', NULL, 'test test', '1', '2009-02-11 08:55:15', -1, '2009-02-12 12:46:57', '1', 0, NULL, 0, ''), (11491, '000000', 'test', '', '', NULL, 'test', '1', '2009-02-12 13:23:08', -1, '2009-02-24 08:37:50', '1', 0, NULL, 0, ''), (11492, '000000', 'tesfasd', '', '', NULL, 'teate asdf', '1', '2009-02-12 13:23:15', -1, '2009-02-13 12:31:26', '1', 0, NULL, 0, ''), (11493, '000000', 'sdfsdf', '', '', NULL, 'teasdfsd', '1', '2009-02-13 18:33:35', -1, '2009-02-24 08:37:02', '1', 0, NULL, 1, ''), (11494, '500642', 'Steve', '', '', NULL, 'Got a new keypad and needs programming.', '1', '2009-02-23 10:55:46', -1, '2009-02-23 10:56:06', '1', 0, NULL, 0, ''), (11495, '000000', 'teset', '', '', NULL, 'test', '1', '2009-02-24 09:44:17', -1, '2009-02-24 13:53:57', '1', 0, NULL, 0, ''), (11496, '000000', 'Test Test', '', '', NULL, 'Testing with new ticket', '1', '2009-02-24 13:54:15', -1, '2009-02-24 14:00:58', '1', 0, NULL, 0, ''), (11497, '000000', 'Test Name', '2620007458', '', NULL, 'Test ticket number 2. Number 2. Number 2. We are having problems and need it fixed. Run away. Run away.', '1', '2009-02-24 14:04:15', -1, '2009-02-24 14:10:18', '1', 0, NULL, 0, ''), (11498, '000000', 'Test Name', '', '', NULL, 'Test', '1', '2009-02-25 07:54:07', -1, '2009-02-25 08:08:55', '1', 0, NULL, 0, ''), (11499, '000000', 'Test Name', '', '', NULL, 'Test', '1', '2009-02-25 08:09:02', -1, '2009-02-25 09:04:03', '1', 0, NULL, 0, ''), (11500, '000000', 'Test Name', '', '', NULL, 'test', '1', '2009-02-25 10:34:54', -1, '2009-02-25 10:35:42', '1', 0, NULL, 0, ''), (11501, '501089', 'Katie', '', '', NULL, 'Just received new pager and it''s not working.', '1', '2009-02-25 10:44:54', -1, '2009-02-25 10:49:20', '1', 0, NULL, 0, ''), (11506, '000000', 'Test Name', '', '', NULL, 'test', '1', '2009-02-26 09:55:53', 0, NULL, NULL, 0, NULL, 0, ''), (11507, '000000', 'Test Name', '', '', NULL, 'test', '1', '2009-02-26 10:06:56', -1, '2009-02-27 12:54:37', '1', 0, NULL, 1, ''), (11508, '500940', 'Dean', '2003067706', '', NULL, 'Left me a VM. Wants to discuss the conversation that I had earlier with Chris.', '1', '2009-02-27 13:11:50', -1, '2009-02-27 13:46:49', '1', 0, NULL, 0, ''), (11509, '000000', 'Test Name', '', '', NULL, 'test', '1', '2009-02-28 22:41:58', 2, NULL, NULL, 0, NULL, 1, ''), (11510, '000000', 'test', '', '', NULL, 'test proactive', '1', '2009-03-13 07:46:28', 0, NULL, NULL, 0, NULL, 3, ''), (11511, '000000', 'Drew', '4140004757', NULL, NULL, NULL, '2', '2009-03-16 16:18:26', -1, '2009-03-16 00:00:00', NULL, 0, NULL, 3, NULL), (11512, '000000', 'Drew', '4140004757', NULL, NULL, NULL, '2', '2009-03-16 16:18:47', -1, '2009-03-16 00:00:00', NULL, 0, NULL, 3, NULL), (11513, '000000', 'Drew', '4140004757', NULL, NULL, 'ddddddddd', '2', '2009-03-16 16:23:14', -1, '2009-03-16 17:23:14', NULL, 0, NULL, 3, NULL), (11514, '000000', '', '', NULL, NULL, 'sdfasdfasdfasdf\r\nasdfasf\r\nasdf\r\nasdf\r\nasdf\r\n', '2', '2009-03-16 16:26:27', -1, '2009-03-16 17:26:27', NULL, 0, NULL, 3, NULL), (11515, '000000', 'dfasf', '3333333333', NULL, NULL, 'ddddd\r\ndddddd\r\ndddddd\r\ndddddd', '2', '2009-03-16 16:27:15', -1, '2009-03-16 17:27:15', NULL, 0, NULL, 3, NULL), (11516, '000000', 'tttttttt', '4444444444', NULL, NULL, 'dafasdfad\r\ndfasf\r\ndf\r\nasdf\r\nasfd', '2', '2009-03-16 16:37:30', -1, '2009-03-16 17:37:30', NULL, 0, NULL, 3, NULL), (11517, '000000', 'tttttttt', '4444444444', NULL, NULL, 'dafasdfad\r\ndfasf\r\ndf\r\nasdf\r\nasfd', '2', '2009-03-16 16:37:41', -1, '2009-03-16 17:37:41', NULL, 0, NULL, 3, NULL), (11518, '000000', 'tttttttt', '4444444444', NULL, NULL, 'dafasdfad\r\ndfasf\r\ndf\r\nasdf\r\nasfd', '2', '2009-03-16 16:38:25', -1, '2009-03-16 17:38:25', NULL, 0, NULL, 3, NULL), (11519, '000000', 'sdfasdfasd', '4444444444', NULL, NULL, 'afasdfasdf<br />\r\nasfasdf<br />\r\nf<br />\r\nasdf<br />\r\nasdf<br />\r\n', '2', '2009-03-16 16:39:44', -1, '2009-03-16 17:39:44', NULL, 0, NULL, 3, NULL); -- -- Dumping data for table `tblticketmessages` -- INSERT INTO `tblticketmessages` (`ID`, `TicketID`, `Message`, `EnteredBy`, `Date`) VALUES (12282, 11492, 'test', '1', '2009-02-13 08:41:50'), (12283, 11493, 'blah blah', '1', '2009-02-20 14:05:26'), (12284, 11493, 'tests test tests test', '1', '2009-02-20 14:05:47'), (12285, 11494, 'Told him I would fax the programming sheet that we previously created for him. Fax#: (888) 888-2672.', '1', '2009-02-23 10:55:58'), (12286, 11495, 'test test test', '1', '2009-02-24 13:47:47'), (12287, 11495, 'test test test New comment', '1', '2009-02-24 13:50:33'), (12288, 11496, 'Test new remark 1.', '1', '2009-02-24 13:56:29'), (12289, 11497, 'Testing of the function of adding the remarks to the portal. I need to verify that the email is going through as programmed.', '1', '2009-02-24 14:08:31'), (12290, 11498, 'Test escalation', '1', '2009-02-25 07:54:26'), (12291, 11499, 'test', '1', '2009-02-25 08:09:15'), (12292, 11500, 'test test', '1', '2009-02-25 10:34:57'), (12293, 11501, 'Walked her through manually programming the pager. Tested and everything working great.', '1', '2009-02-25 10:49:17'), (12297, 11506, 'test 1', '1', '2009-02-26 09:55:58'), (12298, 11506, 'test 2', '1', '2009-02-26 09:56:25'), (12299, 11507, 'test', '1', '2009-02-26 10:06:59'), (12300, 11507, 'test', '1', '2009-02-26 10:07:02'), (12301, 11508, 'Returned call. Explained why he has to change out the base unit.', '1', '2009-02-27 13:15:14'), (12302, 11509, 'test 11509', '4', '2009-03-04 14:40:58'), (12303, 11509, 'test', '1', '2009-03-13 07:45:24'), (12304, 11510, 'test', '1', '2009-03-13 07:46:31'), (12305, 11506, 'test', '1', '2009-03-13 07:56:33'), (12306, 11506, 'test 2', '1', '2009-03-13 07:57:14'), (12307, 11518, 'dafasdfad\r\ndfasf\r\ndf\r\nasdf\r\nasfd', '2', '2009-03-16 16:38:25'), (12308, 11519, 'afasdfasdf<br />\r\nasfasdf<br />\r\nf<br />\r\nasdf<br />\r\nasdf<br />\r\n', '2', '2009-03-16 16:39:44'); That should do it.
-
CREATE TABLE IF NOT EXISTS `tbltickets` ( `ID` int(10) NOT NULL auto_increment, `CustomerNumber` varchar(50) default NULL, `Contact` varchar(50) default NULL, `ContactPhone` varchar(10) default NULL, `Extension` varchar(15) default NULL, `TroubleID` int(10) default NULL, `Summary` longtext, `OpenedBy` varchar(50) default NULL, `DateOpened` datetime default NULL, `Status` tinyint(1) NOT NULL default '0', `DateClosed` datetime default NULL, `ClosedBy` varchar(50) default NULL, `FollowUp` tinyint(1) NOT NULL default '0', `DateFollowUp` date default NULL, `Type` int(1) NOT NULL default '0', `warrantyActivity` varchar(5) default NULL, PRIMARY KEY (`ID`), KEY `tblFacilitiestblTickets` (`CustomerNumber`), KEY `TroubleID` (`TroubleID`), FULLTEXT KEY `Summary` (`Summary`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11520 ; CREATE TABLE IF NOT EXISTS `tblticketmessages` ( `ID` int(10) NOT NULL auto_increment, `TicketID` int(10) default NULL, `Message` longtext character set latin1, `EnteredBy` varchar(50) character set latin1 default NULL, `Date` datetime default NULL, PRIMARY KEY (`ID`), KEY `TicketID` (`TicketID`), FULLTEXT KEY `Message` (`Message`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12309 ; Here are the table structures. Again - thanks for the help.
-
Table tblTickets ID CustomerNumber DateOpened 1 000000 2009-02-26 2 000000 2009-02-28 Table tblTicketMessages ID TicketID Date 1 1 2009-02-27 2 1 2009-03-01 3 1 2009-03-03 4 2 2009-03-04 If the parameters for the "DateFrom" is 2009-02-28 and the "DateTo" is 2009-02-28 the count should return 1. If the parameters for the "DateFrom" is 2009-02-28 and the "DateTo" is 2009-03-03 the count should return 3. Hope this helps and thank you for the assistance.
-
SELECT *, Count(CustomerNumber) AS custCount FROM tblTickets LEFT JOIN tblTicketMessages ON tblTickets.ID =tblTicketMessages.TicketID WHERE Type = 1 AND CustomerNumber = '000000' AND ((tblTickets.DateOpened >= '2009-02-28' AND tblTickets.DateOpened <= '2009-03-01') OR (tblTicketMessages.Date >= '2009-02-28' AND tblTicketMessages.Date <= '2009-03-01')) GROUP BY CustomerNumber ORDER BY custCount DESC; That is the query that exists now, but for some reason it is adding in a count when tblTicketMessages.Date is outside of the end date parameter (2009-3-13). So the count should be 1 because the tblticket.DateOpened = 2009-02-28 and the tblticketmessage.Date = 2009-03-13. But my count is = 2? Any ideas?
-
After trying some different things, this may be a "newbie" way to do it, but it works great: $start = strtotime($datefrom); for($cursor=$start;$cursor<=$enddate; $cursor = strtotime('+1 week',$cursor)) { if($x == 0) { $startyear = date('Y',$start); $startmonth = date('m',$start); $startday = date('d',$start); $startdate1 = mktime(0, 0, 0, date($startmonth), $startday, $startyear); $startdate = date('Y-m-d H:i:s',$startdate1); $nextdate1 = mktime(0, 0, 0, $startmonth, date($startday)+7, $startyear); $nextdate = date('Y-m-d H:i:s',$nextdate1); }else { $startdate1 = $cursor; $startdate = date('Y-m-d H:i:s',$startdate1); $nextdate1 = strtotime('+1 week',$startdate1); $nextdate = date('Y-m-d H:i:s',$nextdate1); //echo date('Y-m-d H:i:s',)$nextdate); } $ecol = $ecol + 1; mysql_select_db('testwork'); $query38 = "SELECT ID FROM tblproactivequestions WHERE Type = 1"; $result38 = mysql_query($query38); $displaystart = date('Y-m-d',$startdate1); $displayend = date('Y-m-d',$nextdate1); $erow = 1; while($row38 = mysql_fetch_array($result38)) { $qid = $row38['ID']; if(isset($_GET[$qid])) { $erow = ($erow + 1); $qid = $row38['ID']; }else { $qid = 0; $erow = $erow; } $query60 = "SELECT SUM(tblproactiveresults.Result) AS SumOfResult FROM tblproactivequestions INNER JOIN (tblproactiveresults INNER JOIN tblproactivecall ON tblproactiveresults.CallID = tblproactivecall.ID) ON tblproactivequestions.ID = tblproactiveresults.QID WHERE tblproactivecall.DateOpened > '$startdate' AND tblproactivecall.DateOpened < '$nextdate' AND tblproactiveresults.QID='$qid' AND tblproactiveresults.Result > 0"; $result60 = mysql_query($query60); $query61 = "SELECT Count(tblproactiveresults.Result) AS CountOfResult FROM tblproactivequestions INNER JOIN (tblproactiveresults INNER JOIN tblproactivecall ON tblproactiveresults.CallID = tblproactivecall.ID) ON tblproactivequestions.ID = tblproactiveresults.QID WHERE tblproactivecall.DateOpened > '$startdate' AND tblproactivecall.DateOpened < '$nextdate' AND tblproactiveresults.QID='$qid' AND tblproactiveresults.Result > 0"; $result61 = mysql_query($query61); $row61 = mysql_fetch_array($result61); while($row60 = mysql_fetch_array($result60)) { $count61 = $row61['CountOfResult']; $result = $row60['SumOfResult']; if($count61 <> 0) { $avg = round(($result / $count61),2); } } } $x = 1; } }
-
Thank you, the for statement is doing exactly what I was looking for!! Thanks again!!
-
I am attempting to use a for loop. $datefrom = $_GET['date1']; $dateto = $_GET['date2']; $start = strtotime($datefrom); $enddate = strtotime($dateto); $oneweek = 604800; for($start=$start;$start<=$enddate; $oneweek) { I would like to add the value of $oneweek to $start during the for so that if the dates were: startdate = '2009-2-1' end date = '2009-2-28' The code inside the for will run 4 times. I can only find the use on the 3 expr in the for to be a var++, which is not working for my use. Any help is awesome. Thanks in advance
-
Thanks, but that sounds a bit out of my league. I am attempting do it with whiles, and possibly arrays, but I have hard time with arrays too. Any ideas on either of those, which I understand better, that would be very helpful. Thanks again.
-
Try $result = mysql_query("SELECT name, username, interests, birthday FROM users WHERE username='$b'"); $row = mysql_fetch_array($result); echo '<br />'.'name: '.$row['name']; echo '<br />'.'name: '.$row['username']; echo '<br />'.'name: '.$row['birthday']; echo '<br />'.'name: '.$row['interests'];
-
Possibly an easier way with less sql: $result = mysql_query("SELECT name, username, interests, birthday FROM users WHERE username='$b'"); $row = mysql_fetch_array($result); echo "<br />name: $row['name']"; echo "<br />name: $row['username']"; echo "<br />name: $row['birthday']"; echo "<br />name: $row['interests']"; NOTE the single quotes around your fieldnames following the row.
-
HI, What I am trying to do: At the end of all of this I would like to have an average of each question selected on the form broken up by the time frame as explained below. I have a form that allows a user to select a start and end date. I would like to break that up into weeks automatically - so if the user selected a start date of 01/01/2009 and end date of 1/31/09, the result would be $startdate = 01/01/2009 $nextdate = 01/07/2009 Run a query using those dates, Then $startdate = 01/07/2009 $nextdate = 01/14/2009 Re-Run the query using the new dates, but still keeping the first queries results. up to the end date. The form also allows the user to select the questions that they would like see the results of. I have named the check boxes the ID's of question. So I can use the $_GET against a query of the ID's in the Question table to find which questions should be included. Tables and Data: tblcall contains the dateopened to compare the start/next/end date variables to. tblquestions holds the questions tblresults holds CallID = tblcall.ID, QID=tblquestion.ID, and the result for each. So tblquestion.ID = 1, tblquestion = a tblquestion.ID = 2, tblquestion = b tblquestion.ID = 3, tblquestion = c But User only Selects 1 and 2 from the form: tblcall.ID = 1, tblcall.DateOpened = 1/2/09 tblresult.CallID = 1, tblresult.QID = 1, Result = 3 tblresult.CallID = 1, tblresult.QID = 2, Result = 2 tblresult.CallID = 1, tblresult.QID = 3, Result = 1 tblcall.ID = 2, tblcall.DateOpened = 1/5/09 tblresult.CallID = 2, tblresult.QID = 1, Result = 8 tblresult.CallID = 2, tblresult.QID = 2, Result = 6 tblresult.CallID = 2, tblresult.QID = 3, Result = 4 tblcall.ID = 3, tblcall.DateOpened = 1/12/09 tblresult.CallID = 3, tblresult.QID = 1, Result = 10 tblresult.CallID = 3, tblresult.QID = 2, Result = 5 tblresult.CallID = 3, tblresult.QID = 3, Result = 15 tblcall.ID = 4, tblcall.DateOpened = 1/13/09 tblresult.CallID = 4, tblresult.QID = 1, Result = 0 tblresult.CallID = 4, tblresult.QID = 2, Result = 6 tblresult.CallID = 4, tblresult.QID = 3, Result = 9 So the output: Week1: 1/1/09 - 1/7/09 Question 1: Avg = ((8 + 3)/2) = 5.5 Questoin 2: Avg = ((6 + 2)/2) = 4 Week2: 1/7/09 - 1/14/09 Question 1: Avg = ((10 + 0/)1) = 10 - a zero value for an answer means it was unanswered and should not count in the average calculation. Questoin 2: Avg = ((5 + 6)/2) = 5.5 Can I accomplish what I am looking for? THANKS IN ADVANCE!!