How to Use Sub Query in Case Expression Archives - Tech Insights https://reactconf.org/category/how-to-use-sub-query-in-case-expression/ Unveiling Tomorrow's Tech Today, Where Innovation Meets Insight Sat, 16 Mar 2013 11:52:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 https://i0.wp.com/reactconf.org/wp-content/uploads/2023/11/cropped-reactconf.png?fit=32%2C32&ssl=1 How to Use Sub Query in Case Expression Archives - Tech Insights https://reactconf.org/category/how-to-use-sub-query-in-case-expression/ 32 32 230003556 How to Use Sub Query in Case Expression https://reactconf.org/selectsubqueryincaseexpression/ https://reactconf.org/selectsubqueryincaseexpression/#respond Sat, 16 Mar 2013 11:52:00 +0000 http://www.sqlneed.com/2013/03/16/how-to-use-sub-query-in-case-expression/ This query returns “High” and “Low” based on their salary compared to the average salary of all employees. SELECT employee_id, first_name, CASE WHEN Salary>=(SELECT Avg(Salary) From Employees) THEN ‘High’ ELSE ‘Low’  …

The post How to Use Sub Query in Case Expression appeared first on Tech Insights.

]]>

This query returns “High” and “Low” based on their salary compared to the average salary of all employees.

SELECT employee_id, first_name,
CASE
WHEN Salary>=(SELECT Avg(Salary) From Employees)
THEN ‘High’
ELSE ‘Low’  END As PAY,
Salary From Employees

SELECT employee_id,Last_Name,
 (CASE
  WHEN Department_Id =
  (SELECT Department_ID FROM Departments WHERE 
  LOCATION_ID=1800)
   THEN ‘Canada’ ELSE ‘USA’ END) Locations
 FROM Employees

The post How to Use Sub Query in Case Expression appeared first on Tech Insights.

]]>
https://reactconf.org/selectsubqueryincaseexpression/feed/ 0 64