I have a table as shown below: I need to select columns based on identity_no and also, need to select non zero/non null column values grouped by src_date. so when I query on the identity_no, I want …
Tag: postgresql
Failed to insert record and return id
I have a query that returns its id after adding DO $do$ BEGIN IF (SELECT COUNT(*) = 0 FROM COMMENTS WHERE PARENT_ID = ”${this.parent_id}’) THEN UPDATE …
Rails Postgres query, selecting only items that appear in all search params with associations
I’m looking to create a Postgres query based on a few user select params. A user will select a shop and a start and end year. Once submitted I’m would only like to display average prices of items if …
PostgreSQL error when removing orders placed closer than 2 minutes apart SQL Error [42803]: ERROR: aggregate functions are not allowed in WHERE
I am getting the following error when removing orders placed closer than 2 minutes apart, but I cannot use HAVING as there isn’t a GROUP BY in the sub query. Am I approaching this correctly and …
Filter duplicate rows in Postgres based on conditions between those rows
Given a table CREATE TABLE data( irs_number VARCHAR (50), mop_up INTEGER, ou VARCHAR (50) ); How would I return all matching records that… have at least one identical value for irs_number in …
Is possible to use an expression logic on @Formula which has a boolean field to compare dates?
I’m trying to know if the following example works with @Formula of hibernate, perhaps someone can help to solve the other ways, to use sql or queries. When I do that example get the following error: 2019-03-03 05:29:57.568 ERROR [service_a,4fedd46e4085e86f,4fedd46e4085e86f,false] 608 — [nio-8090-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: schema “table_a0_” does not exist Position: 5560 2019-03-03 05:29:57.581 INFO [service_a,4fedd46e4085e86f,4fedd46e4085e86f,false] 608 — [nio-8090-exec-1]
How to construct SQL query to select chat participants
I have 3 tables. Users(id, fullname), Chats(id, name) and Chats_Participants(chatId, userId). I need to select all the chats in which user with specified id consists. For example: Chats: 1. 1, ‘Test’…
How can I apply mutliple filters on my sql tables
I am struggling with what looks to be relational division in sql. I need to filter data from the same table based on multiple criteria. Here-under is a schema of what my table looks like. | ——-|–…
How to force postgres to return 0 even if there are no rows matching query, using coalesce, group by and join
I’ve been trying hopelessly to get the following SQL statement to return the query results and default to 0 if there are no rows matching the query. This is the intended result: vol | year ——…
subquery in FROM must have an alias POSTGIS
I am trying using the following query on a POSTGIS (Postgres) Database. The original question: https://gis.stackexchange.com/questions/313252/postgis-sql-query-filter-by-bounding-box SELECT …