SQL timeline and statistical computations

This is simple way how-to generate time table (list of consequencing timestamps, or timeline) in PostgreSQL. Nothing spectacular, but might help you ,when trying to do some time based statistical selects (can feel like OLAP :-)). Code: CREATE OR REPLACE FUNCTION gen_time_list( tim IN TIMESTAMP, tim_stop IN TIMESTAMP, step IN INT) RETURNS TABLE(ts1 TIMESTAMP, ts2 […]

Solving MAX(COUNT()) problem

I’ve been solving problem of doing grouped MAX(COUNT()) in PostgreSQL, and because I’ve not found anything really usable out there (doing correlated sub-queries is definitely not good idea for thousands of records) I’ve had to find my own solution. Situation plan My configuration is a bit complicated to explain this, so i’ll try do it […]