Skip to content

Tag: postgresql

How to convert fields to JSON in Postgresql

I have a table with the following schema (postgresql 14): message are only string, phrases. sentiment is a string, only one word classification are string but can have 1 to many word comma separated I would like to create a json field with these columns, like this: Also, if possible, is there a way to conside…

SQL Group by JSON arrays

So I have a JSON variable (var2), which is an array. I have the following data: I’m trying to write a query that gives back the number of dollars and the machines per group: Example: I’m not used to JSON arrays and it’s kinda tricky for me. I’ve tried many things and I can’t find…

Insert aggreated data from one SQL table to another (Postgres)

I have two SQL tables. This is Votes: and this is votes_aggregate: As you can see each entry in the votes table is a unique vote. I want to aggregate all the individual votes mapping to the same (catalog_item_id, listing_id) to a unique entry in the aggregate_votes table (2nd table). My Postgres skills are pr…

How to create temporal table from current and history?

Let’s say I have a current table that looks like this: and I have a history table that looks as such: How can I build a temporal table such as the following in pure SQL? I am using a PostgresDB is dialect helps! I know I can do this in Python, I’m stuck on calling dynamically named columns using t…

creating a full text index in SQL database

I am searching for a database solution for real full text indexing. I have read Postgres’ full text search chapter but it describes text searching which is not a “full” index and it is heuristic in nature. However I found this https://pgpedia.info/f/fulltextindex.hml contrib/fulltextindex mo…