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
 Code to Determine New Customer

Author  Topic 

blickla
Starting Member

1 Post

Posted - 2010-11-26 : 14:54:09
Hi, I just started a new job and am in the process of learning the environment. Question: How would you code to 'flag' as a 'new' customer per the following rule:

If the customer id is present in month x and is present in month y (next month) then 'Current Customer', If the customer is present in month x and now 'skips' a month (or several months)and is present in month z then 'New Customer'. What is the date function to be used?

blickla

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-26 : 15:10:21
I find that the fastest way to get an answer is to post the ddl of a table, sample data in dml form, sand expected results



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-27 : 01:35:41
are you using SQL 2005 and above?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -