Link to home
Start Free TrialLog in
Avatar of czechmate1976
czechmate1976Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Math operations in SQL query

I have this query:

SELECT orders.issuedate, supplier.supname, orderline.ordref, product.prodcode, product.producttitle, orderline.quantity,
productprice.costprice, productprice.vat, productprice.costprice+productprice.vat as itemcost, quantity*itemcost as itemtotal
FROM orderline, product, productprice, orders, supplier
WHERE orders.ordref = orderline.ordref
AND orders.supid = supplier.supid
AND product.prodcode = productprice.prodcode
AND orderline.prodcode = product.prodcode
AND supname = 'Toyshop'
AND productprice.enddate is null
ORDER BY ORDREF

.. and get this error:

Error at Command Line:2 Column:104
Error report:
SQL Error: ORA-00904: "ITEMCOST": invalid identifier
00904. 00000 -  "%s: invalid identifier"

I am trying to create a derived attribute - item total that shows price including vat and then multiply this 'item total' by the quantity to get the total price for an item on an order.

How can I do it. Can someone help me find the solution to this? Thanks a lot
ASKER CERTIFIED SOLUTION
Avatar of Jarrod
Jarrod
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of czechmate1976

ASKER

Absolutely spot on - I figured it out just before getting the confirmation from you guys. Anyway, thanks a lot.