Skip to content
Advertisement

Tag: postgresql

Avoid ‘out of shared memory error’ in PostgreSQL function

I have two tables, a table called companies_display with information about publicly traded companies such as ticker symbol, market cap etc. and a partitioned table stock_prices with the historical stock prices for each company. I want to calculate the beta of each stock and write that into companies_display. For that I wrote the function calculate_beta(ticker) that calculates it: The function

How to get JSONB array index

I’m sure there’s a simple answer to this but I just can’t find it. I need to obtain JSON array elements as rows, but their index is relevant for the subsequent processing. Here’s a [very simplified] example: I need to get: I’ve tried: But the section column is not computed correctly, as shown below: Answer You can use with ordinality

Pivot with changed structure of the final table

I have the following table – How do I write a query to produce this output – The output table is a connection table between all the columns in the input table. For example, if the value in column A <> column B in the input table then insert a record in the output table. If a value in column

Using group by with order in postgresql

Query: It yields this: What I need is to show those “fightEventId”s that have more than 2 CONFIRMED fights. Currently all records are ordered in the right way, so the result I expect is: How do I do this? Every time I try, I get errors or the order is broken. As for the DBMS used in the project, it’s

Advertisement