How to select avg(select max(something) from ...)

2025-02-18 Thread dfgpostgres
Hi: psql 15.3 I have a table with sets of observations, each set sharing an id. I want to get the average of the max of each set. id | val --- 1 5.0 1 4.3 1 3.8 2 4.8 2 6.0 2 2.9 3 4.1 3 4.4 3 8.0 So I want the avg of the max of the set where id=1 (5

How can I get a query-based subtotal in a select using group by rollup ?

2024-08-07 Thread dfgpostgres
pg 15.3 on linux I don't even know if the title makes sense, I think it's better explained with an example This is the table... dvdb=# \d dispatch_tracker Table "regr.dispatch_tracker" Column| Type | Collation | Nullable | Default