---
title: "What is the difference between a \"where\" clause and a \"having\" clause?"  
description: "What is the difference between a \"where\" clause and a \"having\" clause?"  
author: "Pushpendra Singh"  
published: 2010-10-25  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/88/what-is-the-difference-between-a-where-clause-and-a-having-clause  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# What is the difference between a "where" clause and a "having" clause?

**Difference between a Where Clause and a Having Clause** Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query. **Syntax** **Having Clause:**

```
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
Where Clause
SELECT column_name(s)
FROM table_name
WHERE column_name operator value
```

## Answers

### Answer by Amit Singh

**Difference between a Where Clause and a Having Clause** Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query. **Syntax** **Having Clause:**

```
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
Where Clause
SELECT column_name(s)
FROM table_name
WHERE column_name operator value
```


---

Original Source: https://www.mindstick.com/interview/88/what-is-the-difference-between-a-where-clause-and-a-having-clause

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
