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
 General SQL Server Forums
 New to SQL Server Programming
 data type error ! help !

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2015-02-10 : 23:05:32
I try to compile your query, and prompt error message in below '
conversion failed when converting the varchar value 'times' to data type int .Error code 245.
--------------------------------------------------
select
user_member
, sum(case when trx_date > dateadd(month, -3, getdate()) then 1 else 0 end) + ' times'
, max(case when trx_date < dateadd(month, -3, getdate()) then trx_date else NULL end)
from trx_hdr
group by user_member

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2015-02-11 : 01:13:49
select
user_member
, cast(sum(case when trx_date > dateadd(month, -3, getdate()) then 1 else 0 end) as varchar(10))+ ' times'
, max(case when trx_date < dateadd(month, -3, getdate()) then trx_date else NULL end)
from trx_hdr
group by user_member

--
Chandu
Go to Top of Page
   

- Advertisement -