Skip to content

How can I group data from multiple rows into the same row?

I have a query: That returns I want to combine the rows and take one value from each column (doesn’t matter which, first, last, can be any) So one elementary school, one high school, one university. It would look like: However, when I try to group by: I’m getting only a value for one of the column…

query to update records count based on relation and constraints

Im trying to update a column (address_count) on my people table that must have the sum of records from another table (people_addresses) plus some constraints. The idea is that, the record on people must exist on people_addresses and must be present on at least one of the other tables (table a, table b) With t…

GROUP by data by time range in postgresql

I want to GROUP by data by time range. The example I have start_date and end_date, and I want the separate range between start_date and end_date on 25 range and get sum value from 1 to 25. Simple presentation of my table: table t1 have: generate_series function to separate on and sum by how this 25 for 2019-1…