Question : Please consider the following query: select * from parent p where p.id in ( select p.id from parent […]
Tag: subquery
MySQL select all records unless user must be present in favorites
Question : I am having trouble to find the best solution for the following problem; Description: I want to select […]
Is there anything I can do to optimise this complex query?
Question : I have a rather complex query that spans several layers of subqueries, the two primary ones fetching data […]
Join or Replace colum value based on query
Question : I have this query: SELECT h.name, i.name, i.delay, i.delay_flex, i.status, i.templateid, i.params, i.description FROM items as i LEFT […]
How to perform query operation on another query result
Question : How to get approved , unapproved , deleted count from the below result using sql query. SELECT approved,deleted_at,count(id)AS […]
How to split a SUM column based on another BIT column? [duplicate]
Question : This question already has answers here: mysql: counting number of tickets which are open per day basis (2 […]
LEFT JOIN subquery fails in the presence of an EXISTS clause in the main query
Question : I have this query: SELECT c.id contact_id, engagement.sent FROM contact c LEFT JOIN ( /* ➊ Inner query […]
How to avoid a subquery in FILTER clause?
Question : Schema: CREATE TABLE “applications” ( “id” SERIAL NOT NULL PRIMARY KEY, “country” VARCHAR(2) NOT NULL, “created” TIMESTAMP WITH […]
When to use lateral joins vs correlated subqueries in Postgres?
Question : These two queries: SELECT username, location, task, ts_next – ts AS diff FROM ( SELECT username, location, task, […]
Subquery returned more than 1 value. please help. i beg for mercy
Question : This is may table. In one column there are daily dates and in the other is a classification. […]