We help IT Professionals succeed at work.
Get Started

SQL Query to Show data within 60 Days

Saurabh Singh Teotia
on
473 Views
Last Modified: 2014-12-22
Hi All,

I'm trying to extract data from customer sales table where if the customer is placing sales for the first time it should show as Y basis of sales date but if the same customer return back within 60 days of sales date i want all the entries show as N,However if it returns > 60 days the entry should be Y.

Customer_ID	        Sales_Date
1	                        10-Jan-14
1	                        15-Jan-14
1	                        17-Mar-14
1	                         15-Apr-14

Open in new window


The answer that i'm looking for..

Customer_ID	          Sales_Date	        Answer
1	                          10-Jan-14	          Y
1	                          15-Jan-14	          N
1	                          25-Mar-14	          Y
1	                          15-Apr-14	          N

Open in new window


Saurabh..
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 22 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE