I am hoping you can help with this question. I am using Oracle SQL (SQL Developer for this view)...
If I have a table with the following columns:
- ColumnA (Number)
- ColumnB (Number)
- ColumnC (Number)
In my view I have
Select
ColumnA,
ColumnB,
ColumnA + ColumnB As calccolumn1
Now at this point, I want to use calccolumn1 but I cannot just say...
Select
ColumnA,
ColumnB,
ColumnA + ColumnB As calccolumn1
calccolumn1 / ColumnC as calccolumn2
I am assuming I need some type of subquery..but this is where I need your help... How would I word the query so that I can use calccolumn1 in another calculation within the same query? It might be an If then or a Case when, but bottomline it is some derived number.
(ColumnA + ColumnB) / ColumnC As calccolumn2
? – Alex PooleCROSS APPLY approach
– Lukasz Szozda