Hi All,
I have this below query
SELECT Distinct card_transaction_log.Location,COUNT(card_id),SUM(Amount)
FROM [cwvaluecard].[dbo].[card_transaction_log]
left outer join jjledw1.edw.location.tedw_d_location_type_2
ON CAST(card_transaction_log.Location AS INT) = tedw_d_location_type_2.location_num
where card_transaction_log.Location = '3020'
group by card_transaction_log.Location
which runs fine,and we can see its bringing only for location 3020,however if i want to bring for all the locations, i use this
SELECT Distinct card_transaction_log.Location,COUNT(card_id),SUM(Amount)
FROM [cwvaluecard].[dbo].[card_transaction_log]
left outer join jjledw1.edw.location.tedw_d_location_type_2
ON CAST(card_transaction_log.Location AS INT) = tedw_d_location_type_2.location_num
group by card_transaction_log.Location
I receive the following error,
Conversion failed when converting the varchar value to data type int.
Can someone please help me with any suggestions?
Also, i am going by linked server which can be seen and location in one table is varchar and on the linked server it is INT which is the reason i am casting while joining.
Again any help will be appreciated.
Thanks
I have this below query
SELECT Distinct card_transaction_log.Location,COUNT(card_id),SUM(Amount)
FROM [cwvaluecard].[dbo].[card_transaction_log]
left outer join jjledw1.edw.location.tedw_d_location_type_2
ON CAST(card_transaction_log.Location AS INT) = tedw_d_location_type_2.location_num
where card_transaction_log.Location = '3020'
group by card_transaction_log.Location
which runs fine,and we can see its bringing only for location 3020,however if i want to bring for all the locations, i use this
SELECT Distinct card_transaction_log.Location,COUNT(card_id),SUM(Amount)
FROM [cwvaluecard].[dbo].[card_transaction_log]
left outer join jjledw1.edw.location.tedw_d_location_type_2
ON CAST(card_transaction_log.Location AS INT) = tedw_d_location_type_2.location_num
group by card_transaction_log.Location
I receive the following error,
Conversion failed when converting the varchar value to data type int.
Can someone please help me with any suggestions?
Also, i am going by linked server which can be seen and location in one table is varchar and on the linked server it is INT which is the reason i am casting while joining.
Again any help will be appreciated.
Thanks