Subqueries with comparison operators

Explain the subqueries with comparison operators.

Comparison operators can be used (like <, >, =, !> etc). Sub queries used with comparison operators must return a single value rather than a list to avoid error. Hence the nature of the database must be knows before executing such sub queries.

Example: To display employees who have been referred by John whose id 276
SELECT employeeID FROM employee. employee_name WHERE referenceID = (SELECT referenceID FROM employee.firstname WHERE EmpID = 276)

Example: names of all employees whose salary is greater than the average salery
SELECT Employee_ID FROM Employee.Emp_name WHERE salary > (SELECT AVG (salary) FROM Employee.Emp_name)
Subqueries with Exists and NOT Exists
A subquery with Exist does not really return any data; it returns TRUE or FALSE........
Insert Statement with an example
INSERT: The Insert statement is used to insert values as rows in a table........
Select….into statement with an example
Select into is used to create back up copies of tables. It selects data from one table and inserts into another......
Post your comment