Thivya Posted September 17, 2007 Share Posted September 17, 2007 hi, Again here...here i have problem in sql commands..i am wondering whether is it possible for the sql to calculate average and display data as i wanted....here is my question... I have these values in my table...like this Node_id temperature light voltage Date light accel_x accel_y mag_x mag_y mic _______________________________________________________________________________ 1 25 200 2.5 12.09.2003 0.9877 0.98765 0.766 0.654 232 1 27 466 3.4 13.04.2005 0.8776 0.53442 0.7542 0.342 76 1 34 675 2.6 12.08.2003 0.8775 0.76643 0.87654 0.654 76 1 1 2 2 3 3 4 4 5 5 i need to find the average for all the nodes...each nodes will collect data 5 times..the output should be like this Node1 temperature light voltage light accel_x accel_y mag_x mag_y mic node1 23 ..... node2 34...... I start my command like below...It produced error results... select avg(temperature),avg(light),avg(voltage),avg(accel_x),avg(accel_y),avg(mag_x),avg(mag_y) from suhu HAVING{(suhu.Node_ID="1","2","3","4","5}}; Could someone help?Do i have to come out with 5 sql commands for each node?is that possible?Any other suggestion?doi have to calculate it manually for this case? thank you for your time... Quote Link to comment https://forums.phpfreaks.com/topic/69613-how-i-can-do-sql-command-for-this/ Share on other sites More sharing options...
Barand Posted September 17, 2007 Share Posted September 17, 2007 select Node_ID, avg(temperature),avg(light),avg(voltage),avg(accel_x),avg(accel_y),avg(mag_x),avg(mag_y) from suhu group by Node_id Quote Link to comment https://forums.phpfreaks.com/topic/69613-how-i-can-do-sql-command-for-this/#findComment-350094 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.