Boxiom
Boxiom

Reputation: 2305

Multiplying values from different tables

I have two tables in my database. The first one is Staff, which contains all staff members and ther hourly wage.

staffid     staffname   wage
-----------------------------
1           Joe         15
2           Bill        14

Then there's Hours, which contains the amount of hours each Staff has worked.

staffid     date         hours
------------------------------
1           03.02.2014   8
2           03.02.2014   6

Now what I want to do is to display the amount of money the Staff made each day. So the output could look something like this:

staffid     date        amount
------------------------------
1           03.02.2014  120
2           03.02.2014  84

How would I do this with SQL? Thank you!

Upvotes: 0

Views: 46

Answers (1)

juergen d
juergen d

Reputation: 204894

select s.staffid, 
       h.date, 
       h.hours * s.wage as amount
from staff s
inner join hours h on h.staffid = s.staffid

Upvotes: 1

Related Questions