IN-OPERATOR AND HAVING-CLAUSE IN SQL PYTHON

Diwakar pratap
Mar 21, 2022

--

The SQL IN Operator

· The IN operator allows you to specify multiple values in a WHERE clause.
· The IN operator is a shorthand for multiple OR conditions.

Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, …);

Example

SELECT * FROM Employees
WHERE Country IN (‘Germany’, ‘France’, ‘UK’);

The SQL HAVING CLAUSE

· The HAVING clause is used instead of WHERE with aggregate functions.
· While the GROUP BY Clause groups rows that have the same values into summary rows.
· The having clause is used with the where clause in order to find rows with certain conditions.
· The having clause is always used after the Group By clause.

Syntax

SELECT aggregate_function
(column_names),
column1,column2,…,columnn
FROM table_name
GROUP BY column_name
HAVING aggregate_function(column_name) condition;

Example

Select Sum(Emp_Salary),Emp_City
From Employee
Group By Emp_City
Having Sum(Emp_Salary)>5000;

--

--