I’m really new to SQL and quite struggling with this. I have 2 tables
- MATERIAL (CODE, NAME, BUYPRICE)
- BILL (CODE, DETAIL, AMOUNT)
I want to return a new temporary column TOTALMONEYTOPAID
which is BUYPRICE * AMOUNT
.
Query:
SELECT TOTALMONEYTOPAID FROM MATERIAL, BILL WHERE TOTALMONEYTOPAID = BUYPRICE * AMOUNT
This obviously doesn’t work.
I searched around for something like declare @variable
but I don’t know how to use it. Many thanks with your answer.
Advertisement
Answer
This should be a really simple query:
select Material.Code, Name, Detail, BuyPrice*Amount as TotalMoneyPaid from Material join Bill on Bill.Code=Material.Code