DRod
DRod

Reputation: 15

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.

Upvotes: 0

Views: 870

Answers (2)

SternK
SternK

Reputation: 13101

You should correct your second query in the following way:

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

Upvotes: 0

Julia Leder
Julia Leder

Reputation: 816

Add an alias to the table:

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

Upvotes: 2

Related Questions