Hello,
Let's say there is one simple table, table1 like the below, that stores the type of fruit and their price:
type ; price
apple ; 10
orange ; 5
pear ; 15
Then there is another table, table2, that stores simple transactions (this table looks into table1 to get what type of fruit it is through a combo box):
fruit ; quantity sold
apple ; 7
orange ; 10
apple ; 6
pear ; 2
Now I want to make a query that shows the fruit, the quantity sold, and also the profit, which is: price * quantity sold. My question is: how can I make an expression look for the right price? I would use the lookup function in Excel, but in Access I don't know what would be the most efficient way.
Something like:
IF fruit = X then look for X's price in table1 and multiply it by quantity sold from table2.
The query should look like this:
fruit ; quantity sold ; profit
apple ; 7 ; 70
orange ; 10 ; 50
apple ; 6 ; 60
pear ; 2 ; 30
Do you have any idea?
Many thanks,
Let's say there is one simple table, table1 like the below, that stores the type of fruit and their price:
type ; price
apple ; 10
orange ; 5
pear ; 15
Then there is another table, table2, that stores simple transactions (this table looks into table1 to get what type of fruit it is through a combo box):
fruit ; quantity sold
apple ; 7
orange ; 10
apple ; 6
pear ; 2
Now I want to make a query that shows the fruit, the quantity sold, and also the profit, which is: price * quantity sold. My question is: how can I make an expression look for the right price? I would use the lookup function in Excel, but in Access I don't know what would be the most efficient way.
Something like:
IF fruit = X then look for X's price in table1 and multiply it by quantity sold from table2.
The query should look like this:
fruit ; quantity sold ; profit
apple ; 7 ; 70
orange ; 10 ; 50
apple ; 6 ; 60
pear ; 2 ; 30
Do you have any idea?
Many thanks,