MS Access query that includes a join to itself (using a subquery) and reports values that do not exist (null values)

I have the following table named PRICES: VERTEXID TIMEID PRICE 6001 20191231 104.3 6001 20181231 115.3 6001 20171231 138.3 6001 20161231 122.3 6002 20191231 102.3 6002 20190931 123.3 6002 …

Postgresql – access/use joined subquery result in another joined subquery

I have a database with tables for equipment we service (table e, field e_id) contracts on the equipment (table c, fields c_id, e_id, c_start, c_end) maintenance we have performed in the past (table m,…

Two conditions based on subquery. How to shorten it?

I have working query basing on 2 subqueries. SELECT * FROM database1 where account_id in (SELECT account_id FROM (select account_id,transaction_id from … here i have my big sql query)) and …

Pgsql find similar records in database

I have a table that has the layout of this sensor_id time value 1 2020-12-22 09:00:00 20.5 1 2020-12-22 10:00:00 21.5 1 2020-12-22 11:00:00 22.5 1 2020-12-22 12:00:00 23.5 2 2020-12-22 09:00:00 …

MySQL: Select penult values

There are 2 tables: table1: id |phone| order| —|—–|——| 1 | 122 | 6 | 2 | 122 | 4 | 3 | 122 | 3 | 4 | 123 | 6 | 5 | 123 | 5 | 6 | 123 | 3 | 7 | 124 | 6 |…

SQL – Count rows based on matching columns and value range

Please see below query using T-SQL with SSMS. There are three tables: B, G and L. B has a column Bname G has 2 columns Gname, Gross L has 2 columns Bname, Gname Gross column is an INT ranging …

Select longest duration time (data type field) and client name SQL

I have these tables: CREATE TABLE Client ( client_id NUMBER(10) NOT NULL PRIMARY KEY, name VARCHAR(50) NOT NULL, address VARCHAR(50) NOT NULL ); CREATE TABLE Projects ( project_id …

How to use the results of one query in the next query?

I have read answers here but I am still not quite sure how I would do this regarding two columns of a table and more than one result per query. So, the first query would look like this in my Node app: …

Mysql subquery in where clause that returns comma separated value

I’m not really good at subqueries, here’s the sample tables that I have. table customers ===================== id | name | order_ids 1 | John | 1,2 table orders ===================== id | name 1 …

ms access, need to get all rows with a distinct column

I have a table called “parts” which stores information on electrical connectors including contacts, backshells etc. all parts that are part of an assembly have a value in a column called &…