I have a database from which I call data according to checkboxes checked(Retrieve data from sql database and display in tables - Display certain data according to checkboxes checked). I want to add an option of calculating their average (Between the wanted dates). How can I write a query, calculating the averages when the output is not something specific?
This is the query that calls my data at first place:
$tmp ="SELECT DISTINCT ".implode(",", $sql_columns)." FROM $database_Database_Test.$table_name where DATE>=\"$fromdate\" AND DATE<=\"$todate\"";
How can the average-query call the data according to checkboxes checked + don't average the date and hour column:
$average="SELECT AVG(",", $sql_columns) AS PriceAverage FROM $database_Database_Test.$table_name where DATE>=\"$fromdate\" AND DATE<=\"$todate\"";
Here is my attempt but don't seem to work. The problem is that the AVG is for strings and I want to display an array.