I am getting an error and would your help in getting it solved: Query:-
select
a11.ID_COMPANY ,
a13.ID_CATEGORY ,
sum(a11.sales)
from fact_table a11
join Dimension_Table a13 on (a11.ID_ITEM = a13.ID_ITEM )
Error:- Conversion failed when converting the varchar value 'G100015760' to data type int.
I have checked both fact table and the Dimension table for the ID_ITEM column have the data type of Varchar 20.
when I write cast it successfully runs the query .
select
a11.ID_COMPANY ,
a13.ID_CATEGORY ,
sum(a11.sales)
from fact_table a11
join Dimension_Table a13 on (a11.ID_ITEM = Cast(a13.ID_ITEM as varchar(20)))
So my doubt is when both columns are Varchar data type why I am getting an error and on explicitly adding a cast for the same datatype and length solves the issue.