Relative Content

Tag Archive for postgresqltypeorm

How to remove duplicated rows before group by

I have a query with some filters applied and then I want to use the same query but with one column condition removed to group and count categories on that column to use it as facets and let user know how many results belongs to that category. This is my query for a single facet:

How to do nested sorting in postgresql

I have columns id (string), parentId (string or null) and order (number). It’s tree like structure where rows with the same parentId are children of the same node. order is used to sort children for each parent (so they might be the same for childs of different parents).