Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Error Message Boolean XOR operator

Author  Topic 

meanmyrlin
Starting Member

15 Posts

Posted - 2008-12-10 : 16:06:27
Hello,

I am trying to figure out why I am getting the error message:

"The data types decimal and int are incompatible in the boolean XOR operator."

I am running the query:


Select

IPF.AlgCode, IPF.ChromeStyleid, IPF.NcodeL, IPF.NcodeM, IPF.NcodeR, IPF.SaleYR, IPF.SaleMo, VIN, SaleType, Default_State, IPF.ModelYear, Mileage, SellingPrice, SalesCost, GrossProfit, DaysAtDealerShip, AgeInMo, LogDaysAtDealership,
MileAdjPrice15K, MileAdjPrice21K, SampleSize, AvgDaysAtDealership, AvgMileAdjPrice, AvgLogDaysAtDealer,

((DaysAtDealerShip-AvgDaysAtDealership)*(MileAdjPrice15K-avgmileadjprice)) /
((DaysAtDealerShip-AvgDaysAtDealership)^2)AS SumForLinearAdj,


((LogDaysAtDealerShip-AvgLogDaysAtDealer)*(MileAdjPrice15K-avgmileadjprice)) /
((LogDaysAtDealerShip-AvgLogDaysAtDealer)^2)AS SumForLogLinearAdj


From

dbo.inventoryProFormatted IPF


inner join

(Select AlgCode, ChromeStyleid, NcodeL, NcodeM, NcodeR, SaleYR, SaleMo, Count(vin)AS SampleSize,
ModelYear, Avg(DaysAtDealership) AS AvgDaysAtDealership, Avg(MileAdjPrice15K) AS AvgMileAdjPrice,
Avg(LogDaysAtDealership) AS AvgLogDaysAtDealer


From

dbo.inventoryproformatted

Group by

AlgCode, ChromeStyleid, NcodeL, NcodeM, NcodeR, SaleYR, SaleMo, ModelYear) Averages

on

ipf.algcode = averages.algcode and
ipf.chromestyleid = averages.chromestyleid and
ipf.ModelYear=averages.modelyear and
ipf.SaleMo = Averages.salemo and
ipf.saleyr = averages.saleyr



If I remove the section:

((LogDaysAtDealerShip-AvgLogDaysAtDealer)*(MileAdjPrice15K-avgmileadjprice)) /
((LogDaysAtDealerShip-AvgLogDaysAtDealer)^2)AS SumForLogLinearAdj

The query runs fine. I do not have any boolean statements in the query and the data types of the section causing the error are the same as the ones for the almost identical equation that proceeds it.

Any suggestions would be greatly appreciated. I apologize for the poor formatting; I can't seem to tab or space at the beginning of a line in this window.

Thanks,
Natasha


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-10 : 16:13:40
Instead of using "^" as a mean to multiply with self, because "^" means XOR in t-sql, use

(LogDaysAtDealerShip - AvgLogDaysAtDealer) * (MileAdjPrice15K - avgmileadjprice) / power(LogDaysAtDealerShip - AvgLogDaysAtDealer, 2) AS SumForLogLinearAdj



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

meanmyrlin
Starting Member

15 Posts

Posted - 2008-12-10 : 16:15:03
Thank you so much. I was going crazy trying to figure out where the XOR was coming into play.

Natasha
Go to Top of Page
   

- Advertisement -