Sql condition on temporary column

This article is tagged with: Sql condition on temporary column and mysql

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;
</condition_including:<temp_column_name></column_3_temp_name></column_3_value></column_2_temp_name></column_2_value></column_1_temp_name></column_1_value>

This article is tagged with: Sql condition on temporary column and mysql