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).

Is it possible to use a Stored Procedure as a subquery in SQL Server 2008?

I have two stored procedures, one of which returns a list of payments, while the other returns a summary of …

sql-server stored-procedures subquery
How to alias a field or column in MySQL?

I'm trying to do something like this. But I get an unknown column error: SELECT SUM(field1 + field2) AS col1, …

mysql subquery alias
Can HQL Select on the result set of another query?

Can HQL Select on the result set of another query? For example: SELECT COUNT(*) FROM (SELECT * FROM Table) I can …

java hibernate subquery hql
SQL Oracle LEFT JOIN and SUBQUERY error: ORA-00905: missing keyword

Asking for your help on this Oracle query. It's giving me the error 2 "ORA-00905: missing keyword". It was working fine …

sql oracle subquery left-join ora-00905
WHERE col1,col2 IN (...) [SQL subquery using composite primary key]

Given a table foo with a composite primary key (a,b), is there a legal syntax for writing a query …

sql subquery composite-primary-key
Using CASE, WHEN, THEN, END in a select query with MySQL

I'm working on a baseball related website. I have a table with a batting lineup for two baseball teams: +----+…

mysql select subquery case-when
Oracle: Combine multiple results in a subquery into a single comma-separated value

I'm trying to convert a single-columned subquery into a command-separated VARCHAR-typed list of values. This is identical to this question, …

sql oracle subquery string-aggregation
How do I perform update query with subquery in Access?

I want to port this SQL query, which works just fine on SQL Server, MySQL, and Oracle, to an Access …

sql ms-access syntax subquery
Get records with highest/smallest <whatever> per group

How to do that? Former title of this question was "using rank (@Rank := @Rank + 1) in complex query with subqueries - …

mysql subquery greatest-n-per-group rank
Does SparkSQL support subquery?

I am running this query in Spark shell but it gives me error, sqlContext.sql( "select sal from samplecsv where …

sql apache-spark subquery apache-spark-sql