Answers for "how to create a subquery to add a temporary column in sql"

SQL
1

sql condition on temporary column

-- NOTE: this is for SQL-Oracle specifically

-- syntax:
SELECT *
FROM 
(
  SELECT 
  	 <column_1_value>         <column_1_temp_name>
  	,<column_2_value>         <column_2_temp_name>
  	,<column_3_value>         <column_3_temp_name>
  FROM <_table_name_>
)
WHERE <condition_including:<temp_column_name> >;

-- example:
SELECT * 
FROM 
(
  SELECT
     (AMOUNT)                  TOTAL -- note: NOT ... as "col_1"
    ,((AMOUNT) + (TAX))        TOTAL_WITH_TAX
    ,((AMOUNT) - (DISCOUNT))   TOTAL_WITH_DISC
  FROM SHOPPER
)
WHERE TOTAL_WITH_TAX > 115.00;
Posted by: Guest on April-17-2020

Code answers related to "how to create a subquery to add a temporary column in sql"

Code answers related to "SQL"

Browse Popular Code Answers by Language