February 8, 2018 at 11:45 pm
The Query is below: Thanks in advance, I am learning slowly after decades away from coding!
SELECT AgriculturalProductDetailID AS Prod_ID, APD.HouseHoldID, APD.AgriculturalProductTypeID AS Ag_ID,
APD.PlantationArea,
"PAreaRaponi" =
CASE APD.UnitID
WHEN '1' THEN APD.PlantationArea*1.00
WHEN '2' THEN APD.PlantationArea*13.31
WHEN '3' THEN (APD.PlantationArea*13.31)/20
WHEN '4' THEN (APD.PlantationArea*13.31)/400
WHEN '5' THEN (APD.PlantationArea*0.0625)
END,
February 9, 2018 at 7:56 am
The problem is here:AND ('PAreaRaponi' < 4.34
OR 'PAreaRaponi' > 4.66)
AND 'PAreaRaponi' > 1.0
'PAreaRaponi' is a string and cannot be converted to a number. It looks like you meant to refer to the field PAreaRaponi rather than the string 'PAreaRaponi'. Simply removed the single quotes.
I almost never quote field names, but when I do, I always use brackets instead of single or double quotes. It's unambiguous. In this case that would be [PAreaRaponi].
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
February 9, 2018 at 8:27 pm
Thank you. Certainly a step forward! I still have an error---
with 3 variations, I have errors.......
AND (PAreaRaponi < 4.34
OR [PAreaRaponi] > 4.66)
AND (PAreaRaponi) > 1.0
, 'is One/2/3/14','? ' ) AS "FlagA"
Msg 207, Level 16, State 1, Line 16
Invalid column name 'PAreaRaponi'.
Msg 207, Level 16, State 1, Line 17
Invalid column name 'PAreaRaponi'.
Msg 207, Level 16, State 1, Line 18
Invalid column name 'PAreaRaponi'
Are you able to help again. Thanks
February 10, 2018 at 8:43 pm
noel.moore - Friday, February 9, 2018 8:27 PMThank you. Certainly a step forward! I still have an error---
with 3 variations, I have errors.......
AND (PAreaRaponi < 4.34
OR [PAreaRaponi] > 4.66)
AND (PAreaRaponi) > 1.0
, 'is One/2/3/14','? ' ) AS "FlagA"
Msg 207, Level 16, State 1, Line 16
Invalid column name 'PAreaRaponi'.
Msg 207, Level 16, State 1, Line 17
Invalid column name 'PAreaRaponi'.
Msg 207, Level 16, State 1, Line 18
Invalid column name 'PAreaRaponi'Are you able to help again. Thanks
It's your database. I have no idea what PAreaRaponi means.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
February 12, 2018 at 1:11 am
Thank you for your help Drew. In the remotes of Nepal help is always appreciated!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply