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
 Count total

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2015-02-11 : 23:23:49
I expect this query to count total within 3 month visit to shop member and no visit member total.
-------------------------------------------------
select
count(user_member) as "Total",
case
when trx_date <=dateadd(month, -3, getdate())
then 'Over 3 month non-active ' + max((convert (varchar(20), trx_date)))

else
'active customer '+max((convert(varchar(20), trx_date)))
end as result

from trx_hdr

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-02-12 : 06:54:02
Are you missing a group by clause?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2015-02-16 : 06:58:00
You need to post some sample data with expected result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -