troubleshooting Question

Help with update with join

Avatar of gogetsome
gogetsomeFlag for United States of America asked on
Microsoft SQL Server
4 Comments2 Solutions303 ViewsLast Modified:
Hello, i need some help with the following statement

UPDATE #TempMyDCR
SET MileageAmountPaid =  (E.MileageTotal * (SELECT M.CostPerMile FROM Mileage AS M, Jobs AS J , Timesheets AS T WHERE M.ClientID = J.ClientID  AND      J.JobNumber = T.JobNumber       AND T.TimeSheetId in (Select TimesheetId From #TempMyDCR)))
FROM [Expenses] AS E Join #TempMyDCR AS D
On D.TimeSheetID = E.TimeSheetID

Grateful for any help!


I'm getting the following error:
Msg 512, Level 16, State 1, Line 2
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

Most likely the result of this:
(E.MileageTotal * (SELECT M.CostPerMile FROM Mileage AS M, Jobs AS J , Timesheets AS T WHERE M.ClientID = J.ClientID  AND      J.JobNumber = T.JobNumber       AND T.TimeSheetId in (Select TimesheetId From #TempMyDCR)))
ASKER CERTIFIED SOLUTION
Ephraim Wangoya
Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros