Q

Multiplying fields from different tables

I am trying to multiply two single fields from two different tables and put that answer into a new field in a table. I am trying to estimate the individual Project Costs by taking the Techs rate in the Users table and multiplying it by the Techs individual hourly rate. Each tech has a different hourly rate. The cost will then be displayed for that particular Project Name. Every Project Name has one technician and it is not allowed to have multiple names of Projects. I've been looking online for a week now, and in books, and there seems to be no answer. Help!

Well, let's see if I have it right and can help out. The way I read your questions the two tables would look something like this:

USER
-----
Tech
TechRate

PROJECT
--------
ProjName
Tech
TechIndividualHourlyRate
You want to multiply TechRate by TechIndividualHourlyRate when PROJECT.Tech equals USER.Tech, correct?

How about this?

SELECT P.ProjName, U.TechRate * P.TechIndividualHourlyRate 
FROM   USER U,
       PROJECT P
Or did I miss something?

This was first published in October 2002

Dig deeper on IBM DB2 management

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchAWS

SearchContentManagement

SearchOracle

SearchSAP

SearchSOA

SearchSQLServer

Close