---
title: "What are subquery and its properties in SQL server?"  
description: "What are subquery and its properties in SQL server?"  
author: "Ashutosh Patel"  
published: 2023-03-22  
updated: 2023-03-22  
canonical: https://www.mindstick.com/forum/157538/what-are-subquery-and-its-properties-in-sql-server  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 1 minute  

---

# What are subquery and its properties in SQL server?

What are [subquery](https://www.mindstick.com/forum/1279/using-alias-in-subquery) and its [properties](https://www.mindstick.com/articles/23331/nootropics-7-different-types-and-their-unique-properties) in [SQL server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server)?

## Replies

### Reply by Krishnapriya Rajeev

Subqueries are queries that are placed inside another query. The outer query is called as the **main query** and the inner query is called **the subquery**.

Different types of subqueries are:

1. Single-row sub-query - the sub-query returns only one row.
2. Multiple-row sub-query - the sub-query returns multiple rows
3. Multiple column sub-query - the sub-query returns multiple columns.

Properties of subqueries include:

1. Subqueries can be used with SELECT, UPDATE, INSERT, or DELETE statements.
2. It can be placed in the WHERE clause, HAVING clause, and FROM clause.
3. It is enclosed in parentheses.
4. It is always placed on the right side of comparison operators.
5. We cannot use the ORDER BY clause in the subquery. But, we can use the GROUP BY clause, which performs the same function as the ORDER BY clause.
6. The inner query executes before its parent query and the results of an inner query are passed to the outer query.
7. BETWEEN operator is placed within the subquery and cannot be used with the subquery.


---

Original Source: https://www.mindstick.com/forum/157538/what-are-subquery-and-its-properties-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
