Skip to content

Tag: postgresql

PostgreSQL group by column with aggregate

I need to group by id and select the task with min/max seq as start and end But this results in But I do not want group by seq Answer One method uses arrays: Another method uses window functions with SELECT DISTINCT:

How to escape several with in the query?

I need to refactor my query, but I have no idea, how to do this. I can see several duplicates of using the same logic, but I continue to repeat this manner of querying from query to query, and I feel, that this kind of querying becomes my main frame of thinking of SQL and I don’t want this. Could

Using update inside of PL/pgSQL

To begin with, I am a newbie to SQL and PostgreSQL. It might be a silly beginner’s mistake. ^This isn’t working provides me with an error SQL Error [42601]: ERROR: syntax error at or near “update” Where: PL/pgSQL function temporary_function_for_getting(text,bigint,json) line 13 at RETU…