Jump to content

Doing calculations inside a database?


sorenchr

Recommended Posts

Hi!

 

Straight to the question. Im currently creating a portal system, in which I would like to create a statistics section. The statistics that I provide are calculations of raw data in the database, so for example, I would create a statistic property that calculates an avg. of new user accounts pr. day. Perhaps I should explain a little more in detail. When a user creates an account, the date is logged to the database along with the users new data. So instead of issuing a query that counts every user that is created that date, can I then get MySQL to count every new account in the db (sorted by date) and output that data into a new mysql table which I can then just echo on the website?

Link to comment
https://forums.phpfreaks.com/topic/107865-doing-calculations-inside-a-database/
Share on other sites

You can Query for the AVG, MIN, MAX, STD of a field see examplebelow

$string1e = "SELECT 
round(AVG(IR_100_kA),2) as Avg_IR_100_kA, 
round(MIN(IR_100_kA),2) as Min_IR_100_kA, 
round(MAX(IR_100_kA),2) as Max_IR_100_kA, 
round(STD(IR_100_kA),2) as Std_IR_100_kA
FROM tblhighcurrent where QA_Block_Batch_ID = '".$QA_Block_Batch_ID."'";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.