SQL HAVING - Introduction and syntax
SQL - Dec 03, 2008 at 18:00 PM by Rajmeet Ghai
Explain the SQL HAVING statement. Write SQL syntax for the SQL HAVING statement
along with an example.
HAVING clause is used to specify some condition along with
aggregate functions.
Syntax:
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
Example:
SELECT emp_id,SUM(salary) FROM employee
WHERE employee_name='tom’
GROUP BY emp_id
HAVING SUM(salary)>1500
SQL UNION ALL: The UNION ALL operator is used to combine the result-set of two
or more SELECT statements Tables of both the select statement ................
SELECT DISTINCT: It is used to select unique records from a table. Some tables
may have duplicate values for a column. Distinct will eliminate these
duplications...........
GROUP BY: It is used with aggregate functions to group the result-set by one or
more columns................
SQL CREATE VIEW: A view is a virtual table. A view contains rows and columns,
just like a real table..............
SQL CONCATENATE: This clause combine together (concatenate) the results from
several different fields...............
SQL BETWEEN
SQL BETWEEN: The BETWEEN operator is used in a WHERE clause to select a range of
data between two values. The values can be numbers, text, or
dates..............
|