Skip to content
Advertisement

How to calculate the a third column based on the values of two previous columns?

My sample data is as follows:

Table T1:

Table T2:

Now, my requirement is to fetch the data in the following form:

I am able to get the data of the first three columns using:

My question is: Is there a way to calculate the third column using the calculated values of columns 2 and 3 instead of writing down the entire formulas used to calculate those 2 columns? The reason is that the formula for calculating the third column is not small and uses the values of 2 and 3 multiple times.

Is there a way to do something like:

What would you suggest?

Note: Please ignore the syntax used in the CASE expressions used above, I have used it just to explain the formula.

Advertisement

Answer

by usuing sub-query you can do that

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement