I have a Postgres database configured as my persistence layer and would like to execute SQL queries against the Postgres tables cached in Ignite. Ideally, I’d like to execute a query on these caches and be returned the Value objects represented by these tables. SqlQuery gives me the functionality that I…
Tag: postgresql
SQL – Get value of column for rows matching a string AND a list of strings not found in the table?
I have a table that has (among other things) a “serial number” (VARCHAR(50)) column and an “active” (BOOLEAN) column… so a sample of data might look like this: Now, from an outside source, I am given a list of serial numbers, like so: Is there a single (ideally) query or series o…
SQL average of a subset of a column
Give the table “shop” Is there a way to find the list of products(whether A or B) whose price is less or equal to the average price or type A? I tried the following: Answer Use a subquery to find the average price of type A items: Just for fun, we could also use analytic functions here: Demo
Sort full join based on two columns on two different tables
I have two tables in my PostgreSQL database (Table A and Table B). Both of these tables have a createdAt column. I want to do a full join on these two tables and then sort the result based on createdAt values on both A and B tables. Below is an example of what I want to be my query result.
How to fix SELECT statement to return duplicates
Currently I am trying to return a three table join to find duplicate track titles that are in my a “track” table, and also return the track number | cd title from the other joined tables. My select statement is currently returning all the information from the joined tables but its not showing only…
How to add counter id column based on several columns on SELECT query Postgresql
I would like to create a column with counter number based on question_id and matrix_question_id this is my query: and this is the result I would like to create a new column as id_counter represent id counter base on question_id and matrix_question_id and I wish the result like this Answer What you need here i…
Django complex partitioning & ordering for tree Table
I’m using Django with PostgreSQL as my Backend-Stack for an application of which the main feature is a complex, multilevel table displaying annotated time-series-data for different products. So …
SQL how to fill out first line of group with value and other values to null
Actually i have a select statement which contains a group by I would like this : How to do that (test value fill in first row group) with sql (pgsql) ? thanks ! I tried Partition by… Answer demo:db<>fiddle Enumerate all records of an ordered group to find the first one using the row_number() windo…
How to query for the difference between the sequences of two columns, from differing tables
I need a query that will compare the sequences of two columns (from two different tables) and display the first differing result. Summary with details follow: Operating out of a PostgreSQL server and using DBeaver Two tables with identical column headers. One entry (creq_id) will have 36 sequences (seq). When…
How to extract values from array json column into multiple rows in Postgresql?
How can I extract values from the json arrays in ranges column as multiple rows Postgresq? Expected result: Start End 1 100 101 1000 1001 2000 2001 2002 Answer You can use jsonb_to_recordset function for this : http://www.sqlfiddle.com/#!17/22d62/10