hi working postgresql database. need calculate average time between records fetching 1 table.
schema:
create_table "user" |t| t.text "status" t.datetime "time" t.datetime "updated_at" end
example:
- select time users status = 'now';
- select time users status = 'after';
on results of above queries need perform average time. need combine 2 queries 1 query. tried union operator, whether right way use?. appreciated..
you should consider using sql select avg() function, each group. e.g.,
select status, avg(time) users status = 'now' or status = 'after' group status
Comments
Post a Comment