Total Page Preview:   000000000270

What is Having function in SQL in English and Hindi

 

 SQL Having  function in Engilsh

In SQL, a function is a pre-defined or user-defined routine that can accept input parameters, perform specific operations, and return a result. Functions can be used to simplify complex calculations or queries, and they can be used in various parts of SQL queries such as SELECT, WHERE, HAVING, ORDER BY, and GROUP BY clauses.

The HAVING clause is used to filter the result set of an SQL query based on a condition that is applied to the result of an aggregate function. Here's an example of using the HAVING clause with an aggregate function:
here's an example of using the HAVING function in SQL with a tabular representation:
 
Consider a table named "orders" with the following data:
To find the total orders for each customer, we can use the following SQL query:
The result of this query will be:
Now, suppose we want to find only those customers who have placed more than one order. To do this, we can use the HAVING function as follows:
The result of this query will be:
In this query, the HAVING function filters the result set to only include customers who have placed more than one order, by checking the count of orders for each customer and selecting only those customers whose count is greater than 1.
 
 
 
 

SQL Having  function in Hindi

SQL mein, HAVING function ek aisa function hai jo result set ko aggregate function ki output ke basis par filter karne ke liye istemal kiya jata hai. HAVING function GROUP BY clause ke baad istemal kiya jata hai. Yeh function WHERE clause se different hota hai kyunki yeh aggregate function ke basis par filter karta hai jabki WHERE clause non-aggregate function ke basis par filter karta hai.
 
Yahan ek tabular example diya gaya hai jismein HAVING function ka istemal kiya gaya hai:
Maan lijiye humare paas ek "orders" table hai jismein kisi company ki orders ki jaankari hai. Har order ke liye order id, customer id, order date aur order total shamil hain. Har customer ke liye total orders ki jaankari dhoondhne ke liye, hum neeche diye gaye SQL query ka istemal kar sakte hain:
 
 
Is query ka result set niche diya gaya hai:

Ab maan lijiye ki hum sirf un customers ko dhoondhna chahte hain jo ek se zyada orders place kiye hain. Is ke liye, hum HAVING function ka istemal kar sakte hain, jaisa ki neeche diya gaya hai:

Is query ka result set niche diya gaya hai:

Is query mein HAVING function result set ko filter karta hai aur sirf un customers ko shamil karta hai jo ek se zyada orders place kiye hain. Is ke liye, COUNT aggregate function ko istemal kiya jata hai jo har customer ke orders ki ginti ko count karta hai.

 

 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: