This topic is locked
[SOLVED]

 Maximum, Minimum, and Standard Deviation on List Page

5/25/2014 2:58:32 PM
PHPRunner General questions
D
dangdk author

Hi,
I am using the PHPR "Totals Type" function to display a line showing the average of my columns in the list page. However I also want additional lines that each display the maxmimum, minimum, standard deviation, and COUNT of each column. How can I do this?
Thanks

Davor GeciDevClub member 5/26/2014



Hi,
I am using the PHPR "Totals Type" function to display a line showing the average of my columns in the list page. However I also want additional lines that each display the maxmimum, minimum, standard deviation, and COUNT of each column. How can I do this?
Thanks


Hello dangdk,
maybe you can use some SQL tricks with UNION ALL.

Something like this:

(Adds adional row on end)

SELECT category,

color,

Horsepower,

id,

Price,

zipcode

FROM carscars

WHERE 1=1
UNION ALL
SELECT 'TOTALS: ',

'',

'',

'CountID: ' & count(ID),

'MinPrice: ' & Min(Price),

'MaxPrice: ' & Max(Price)

FROM carscars

WHERE 1=1


OR

SELECT category,

color,

Horsepower,

id,

Price,

zipcode,

'' As CountID,

'' as MinPrice,

'' As MaxPrice

FROM carscars

WHERE 1=1
UNION ALL
SELECT 'TOTALS: ',

'',

'',

'',

'',

'',

count(ID) As CountID,

Min(Price) as MinPrice,

Max(Price) As MaxPrice

FROM carscars

WHERE 1=1


Keep an eye, with the UNION ALL number of columns in both SQL's (or more) must be the same and the WHERE clause must be the same
Regards, Davor

Sergey Kornilov admin 5/26/2014

I would suggest to implement this using code snippets. You can insert a few code snippets using Visual Editor and add PHP code that runs corresponding GROUP BY SQL query for each field and displays results.

D
dangdk author 5/30/2014

Thanks