Top "Subquery" questions

"subquery" is vague SQL terminology, used to describe when there's either more than one `SELECT` statement in a query, or when used in Data Manipulation Language (DML) statements (IE: DELETE, UPDATE, INSERT, MERGE).

SQL Server: join on derived table that contains WITH clause?

I'd like to join on a subquery / derived table that contains a WITH clause (the WITH clause is necessary to …

sql-server subquery row-number derived-table
How to use a MySQL column alias for calculations?

How can I use my column alias (lat and lng) from the two subqueries to make the distance calcuation underneath? …

mysql subquery alias calculated-columns
MySQL NOT IN with subquery not working as expected

I'm creating a application that will generate lists for email marketing campaigns. I have tables for contacts, emails, and campaigns. …

mysql subquery notin
Subqueries in CakePHP 3?

I have two tables products and product_categories that are associated through a third table, products_categories_products, according to …

cakephp subquery conventions cakephp-3.1 cakephp-3.x
Using MAX with multiple tables

I have a four tables: products, pc, laptop, and printer. Products(maker, model, type) PC(code, model, speed, hd, cd, …

sql subquery union aggregate-functions multiple-tables
t-SQL to find Top 10 Records for Each Group

I am trying to figure out how to return the top 10 records for each group of Trans.TranSID. SELECT a.…

sql tsql subquery row-number
NOT IN Operator not working as expected in Oracle

I have two tables: PROD and CUST On running the below query in SQL and SYBASE, it works. Oracle is …

oracle null subquery notin
How to impose LIMIT on sub-query of JPA query?

Is it possible to impose LIMIT on sub-query in JPA query ? I have following query in pure SQL select * from …

jpa subquery jpql
Tuple result Criteria API subquery

I am trying to use subqueries in an application I am writing using JPA 2.0 type-safe criteria API, with Hibernate 3.6.1.Final …

jpa subquery criteria jpa-2.0 criteria-api
MySQL using IN/FIND_IN_SET to read multiple rows in sub query

I have two tables, locations and location groups CREATE TABLE locations ( location_id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, name …

mysql subquery in-subquery