Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I multiply a field result in a query? 1

Status
Not open for further replies.

Apollo13a

Technical User
Apr 27, 2003
277
US
Hello, I have a query that returns labor hours from a table. I want to multiply the fields OT and DT by 1.5 and 2 respectively.
Here's my sql
Code:
SELECT tblContractor.Contractor, tblJobs.JobName, tblHours.ST, tblHours.OT, tblHours.DT, tblHours.Shift, tblHours.WorkDate, DatePart("q",[WorkDate]) AS Cquarter, Format([WorkDate],"ww",2) AS Cweek, tblContractor.tblContractorID, tblHours.ST AS PensionS, tblHours.OT AS PensionOT
FROM (tblContractor INNER JOIN tblJobs ON tblContractor.tblContractorID = tblJobs.Contractor_ID) INNER JOIN tblHours ON tblJobs.tblJobs_ID = tblHours.Jobs_ID
GROUP BY tblContractor.Contractor, tblJobs.JobName, tblHours.ST, tblHours.OT, tblHours.DT, tblHours.Shift, tblHours.WorkDate, DatePart("q",[WorkDate]), Format([WorkDate],"ww",2), tblContractor.tblContractorID, tblHours.ST, tblHours.OT
ORDER BY tblHours.WorkDate, DatePart("q",[WorkDate]);
thanks Jim
 
Code:
SELECT tblContractor.Contractor
     , tblJobs.JobName
     , tblHours.ST
     , [red]tblHours.OT * 1.5  AS OT_and_a_half[/red]
     , [red]tblHours.DT * 2    AS DT_doubled[/red]
     , tblHours.Shift
     , ...
may i ask why you are grouping? i don't see any aggregation (sums or counts)...

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top