Skip to content
Advertisement

Tag: postgresql

Performing division with PostgreSQL / json

I have written a simple query against a table in a Postgres database that contains a column “manifest” of type json. Each cell contains a very long value and I am extracting the numerical value for “size”. I need to create a new column (perhaps call it “size in MB”), and perform division against size. Specifically, I need to take

Hide duplicate column cells in view

First of all, this here doesn’t solve my problem at all. I tried this too. I want generate random unique fake data (first name and address) I used the following SQL request: The result apparently looked like this (the addresses repeat themselves for the next name too): How do I make the first names AND addresses unique? Please note this

PostgreSQL: Trigger INSERT INTO SELECT from other table

I’m trying to create a trigger that will add a new row processed entry to a destination table each time a new row is created in the source table. Step 1 Create destination table: Step 2 Create trigger function: ** The Select query inside function work normally when single running. Step 3 Create trigger: The problem is that Trigger does

How to make postgres not use a particular index?

I have the following query: As you can see, the cost of the last index scan on chaindata_tokentransfer_chain_id_block_number_tx_eeeac2a4_idx is very high. And the query is timing out. If I remove the filter on chain_id and block_number from the query, then the query is executing in a reasonable amount of time. Since this new less constrained query is working, I’d expect

Difference between CREATE CAST and CREATE CONVERSION

In postgres, it seems there are two customizable ways to convert one value type into another via SQL, CREATE CONVERSION and CREATE CAST. What is the difference between these two items, for example what might be an example of where one might be used over another? Answer A cast has nothing to do with a conversion. A cast converts data

Postgresql Get Maximum value per day with corresponding time

I have the following table: I want to get maximum value along with Date,ReceivedTime. Expected Result: Answer This answer assumes that, in the event of two or more records being tied on a given day for the same highest value, you want to retain the single record with the most recent ReceivedTime. We can use DISTINCT ON here:

Advertisement