In Postgres, I am trying to aggregate results from a table that looks like this: id restaurant_id title category ————————————————- 1 2 …
Tag: postgresql
Postgres jsonb field to array
I was going through the Postgres Jsonb documentation but was unable to find a solution for a small issue I’m having. I’ve got a table : MY_TABLE that has the following columns: User, Name, Data and …
dotnet Entity Framework INSERT SELECT FROM other table
I am not an expert on databases and SQL. I am developing a dotnet core application using the Entity Framework to access a (postgresql) database. I have the following tables with the following columns: …
How to group by incuding UID column in the new table
I ‘m trying to group some data with the following query but I need also to add the uid column from a_import.veg table in the c_schema.worst_case table which contains unique values. As far as I know I …
Speed up query on JSONB object field Postgres / indexing a JSONB field
I am trying to speed up queries on an object field in Postgres. The table I am searching has the following structure: page_id: integer lang: varchar(2) images: jsonb The images JSONB field contains …
Postgresql – How to identify latest record of a combination of 2 columns (Example inside)
In PostgreSQL, if i have this kind of record : |——————|———————|——————| | corona_country | corona_patient | corona_suspected | |——————|———…
SQL query 2 limits
I have the following issue i want to limit on the total amount of items returned while limiting one value to a certain number I do a query like this Now I want to do the following, I have a field called running and I want to be able to say that in these results I want to have maximum
Execute sql queries from shell script
I need to execute the following sql queries from bash/expect script what is the preferred approach to run these queries from bash script # psql ambari -U ambari Password for user ambari: psql (9.2.24)…
SQL Query for Events table
I have an event table in Postgres, with this structure: This works as a log, so all entries are immutable, change is status will be another INSERT. I want to efficiently extract all events which have status CREATED, but not DONE. Answer I assume that you want ITEMs that meet the conditions. If so: This uses the fact that ‘CREATED’
Is there a way to substitute GROUP BY
I have two tables i’m working with: comporder(quantity,cod(Fk on cod(product),cod_ship); product(cod(Pk),price); I need to produce a query that will give me the sum of the prices of the products that …