I'm comparing two tables that should have the same data. I've got a couple of different queries that are supposed to return rows that don't match. However, the queries return rows that DO match. I'm not sure why. Here is an example:
select
which = 'TableA',
*
from (
select * from compareTempA
except
select * from compareTempB
) x
union all
select
'TableB',
*
from (
select * from compareTempB
except
select * from compareTempA
) x
order by dateindex, empid, serviceSales, productSales
For some reason I get results like the following:
As you can see these rows appear to match. I've also tried:
select sum(case when A.productSales = B.productSales then 0 else 1 end) from
compareTempA A
join compareTempB B
on A.dateindex = B.dateindex
and A.empid = B.empid
and A.storeid = B.storeid
To which I get 3011. I'm baffled because the data is supposed to be the same in both tables. The only thing I can think of is that I formed the two tables by inserting into each of them in the following way:
insert into compareTempA
select * from someView
And I did the same for compareTempB. I tried truncating the tables first and reinserting. Please help!