Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi

I am trying to update a temp table with the sum of a couple of field from another table that is joined and I get the following error message with this piece of code.

"An expression of a non-Boolean type specified in a context where a condition is expected"

The code is as follows....

UPDATE #TempTable
SET TOTAL_AREA = AreaTotal,
TOTAL_AREA_VALUE = AreaTotalValue
FROM #TempTable INNER JOIN
(
SELECT SUM(tblWhereTotalsAre.AreaTotal) AS AreaTotal,
SUM(tblWhereTotalsAre.FinalValueTotal) as AreaTotalValue
FROM tblWhereTotalsAre INNER JOIN
tblHeader ON tblWhereTotalsAre.FK_ID = tblHeader.ID
WHERE tblWhereTotalsAre.ItemType = 'BUILDING'
GROUP BY tblWhereTotalsAre.FK_ID, tblHeader.Property, tblWhereTotalsAre.ItemType
)

Any idea where I am going wrong or missing.

I want to update 2 field in the temp table from a group clause in another table that has a sum.

What I have tried:

I have tried various ways but still get the error message. Tried instead of where used the having but still have a fault.
Posted

1 solution

You didn't specify the ON clause for the INNER JOIN, so SQL has no idea how to tie the two tables together. (Silly message though)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900