Skip to content

Tag: postgresql

Update with a subquery and a join

How do I update table1 with results of this query – I want to do something like this – Answer This question has been answered many times in SO… anyway, the query should be built this way One option Other option Surely there are other additional ways…

How to convert generic XML to a table row in PostgreSQL?

PostgresSQL v12.5 There is a table with single column containing strings formatted as XML. For simplicity let’s claim that there are no nesting: all tags inside <something> contain primitive values (strings). Assuming that there are much more elements than <a> and <b> inside, it would …

SQL syntax to achieve the “opposite” of LIKE

I’m very rusty on the little SQL I once learned, and while I totally get SELECT column1 FROM table WHERE column2 LIKE pattern, what I need is: For example, I might have a product family table which has information about the Coca Cola range, and for which I might store coca% in column2 ready to match spe…

Getting row samples from PostgreSQL

I have a data table with timestamp and some data columns. The rows are inserted in arbitrary time intervals, i.e. the timestamp difference of consecutive rows is not stable but ranges from several seconds to several hours. I need to select one row per time interval of constant length, if there is any. Example…

How can I show values with zero in a Group By query

I am trying to get the zero values from my status table associated with the case of one user. So, I have this query that returns me only one value because, I have only one case associated with one status but I want to receive also the another status with value 0. So I have the status ‘Open’ and &#…