SQL query to divide output?

Associate
Joined
5 Mar 2010
Posts
392
Location
Brighton
Hi all,

I'm fairly new at postgres sql so bare with me,

I have been tasked to query a database to get the totals of entries for something, divide it by 50,000, round up the result and then output to csv.

I've managed to get this far, which is showing the totals I need:

SELECT context_trial_name, COUNT(*) FROM status.page GROUP BY context_name;

I just need to do the rest and I'm getting confused as to how?

Thanks in advance....
 
Code:
SELECT context_trial_name, 
       ROUND( (COUNT(context_trial_name) / 50000 ), -1 )

FROM status.page

GROUP BY context_name;

-1 will round to the nearest 10 ... for example 177.54 would round to 180.00

If you need to round 177.54 to 178.00 use 1, 177.50 use 2.. etc, etc..
 
Last edited:
Back
Top Bottom