Skip to content
Advertisement

SQL Oracle: selecting all data and then multiply two columns

I am trying to display all data from a table, take two columns and multiply them and place the result in a new column at the end. Can I use the ‘*’ and then multiply or do I have to select each column individually?

This displays my desired result using the JustLee database in OracleLive but I have to select each column.

select order#, item#, isbn, quantity, paideach, quantity * paideach as "Item Total" 
from orderitems;

Is it possible to combine the ‘*’ and then multiply two columns? Below is around what I am looking for.

select *, quantity * paideach as "Item Total"
from orderitems;

Thanks.

Advertisement

Answer

You should correct your second query in the following way:

select orderitems.*, quantity * paideach as "Item Total"
from orderitems;
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement