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
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."'";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.