How to Use ALL Keyword in SQL
In this article I am going to explain how to use ALL Keyword in SQL.
Introduction
In this article I am going to explain how to use ALL Keyword in SQL. A select statement known as subquery if it is codded within another SQL statement. Subquery can return a single value or a result set. This result set may contain a single column or more than one column.
There are four way to create subquery in a SELECT statement.
- In WHERE Clause
- In HAVING Clause
- In FROM Clause
- In SELECT Clause
ALL Keyword in SQL is used to test that a comparison condition is true for all of the value return by subquery. We use ALL keyword with comparison operators like >,<,>= and <= .
Example
SELECT * FROM dbo.mcninvoices
WHERE invoicetotal > ALL
( SELECT invoicetotal
FROM dbo.mcninvoices WHERE invoiceid = 8)
|
Output