About 10,400 results
Open links in new tab
  1. 5 SQL Subquery Examples - LearnSQL.com

    Nov 18, 2021 · Here are 5 SQL subquery examples demonstrating how to use scalar, multirow, and correlated subqueries in the WHERE, FROM, JOIN, and SELECT clauses.

  2. How to Use a Subquery in a SELECT Statement - GeeksforGeeks

    Jan 2, 2025 · In this article, We will learn about Subquery in a SELECT statement by understanding various examples and output in detail. A subquery (also known as a nested query or inner query) is a query placed inside another query. The subquery returns a result that is used by the outer query.

  3. SQL Subquery - SQL Tutorial

    Subquery in the SELECT clause # The following example uses a subquery in the SELECT clause to retrieve the first name, salary, and average salary of all employees: SELECT first_name, salary, ( SELECT ROUND (AVG (salary), 2) average_salary FROM employees ) FROM employees ORDER BY salary; Code language: SQL (Structured Query Language) (sql) Try it

  4. SQL Server SUBQUERY with Examples - SQL Server Tutorial

    subquery – the SELECT query within the main query which provides input to the main query for further processing. table_name – the table on which the main query or statement operates. Let us understand the different subquery types with the help of some examples.

  5. SQL Subquery – How to Sub Query in SELECT Statement

    Oct 4, 2022 · This article showed you what you need to know about SQL subqueries and how to use them with the SELECT statement. However, subqueries are not limited to the SELECT statement only. You can use subqueries in all the CRUD operations of SQL – INSERT, SELECT, UPDATE, and DELETE.

  6. SQL Subqueries - w3resource

    Feb 13, 2025 · What is subquery in SQL? A subquery is a SQL query nested inside a larger query. A subquery can be located in: - A SELECT clause - A FROM clause - A WHERE clause - A HAVING clause; The subquery can be nested inside a SELECT, INSERT, UPDATE, or DELETE statement or inside another subquery.

  7. SQL Server Subquery Example - MSSQLTips.com

    May 13, 2019 · A subquery is a SELECT statement embedded in another SQL statement, such as a SELECT, INSERT, DELETE, or UPDATE statement. The set of value(s) returned by the inner SELECT statement are passed to the outer SQL statement.

  8. SQL Subquery (With Examples) - Programiz

    In SQL, a SELECT statement may contain another SQL statement, known as a subquery or nested query. FROM Customers. WHERE age= ( -- subquery SELECT MAX(age) FROM CUSTOMERS. Here, the query is divided into two parts: SELECT column FROM table . Here, FROM Customers. WHERE age = ( SELECT MIN(age) FROM Customers.

  9. How to Use SELECT with Multiple Subqueries to Same Table in SQL

    Oct 12, 2024 · In this tutorial, we’ll explore using subqueries in SELECT, WHERE, and FROM clauses and show how to handle them when they become repetitive (and redundant). All our examples are based on our University database schema. 2. Understanding Subqueries in SQL. A subquery, also known as a nested query, is a query inside another SQL query.

  10. SQL | Subquery - GeeksforGeeks

    Apr 14, 2025 · What is SQL Subquery? In SQL, a subquery can be defined as a query embedded within another query. It is often used in the WHERE, HAVING, or FROM clauses of a statement. Subqueries are commonly used with SELECT, UPDATE, INSERT, and DELETE statements to achieve complex filtering and data manipulation. They are an essential tool when we need to ...