subquery that add temporary column in sql code example
Example: 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;