vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-10-25 : 05:45:31
|
Hello everyone,Please help me in this scenario.Table Structure and sample data[CODE]CREATE Table MobileCustomers( CustomerID Int, Usage Money, UsageDate DateTime )INSERT INTO MobileCustomersSELECT '1','8','10/20/10' UNION ALLSELECT '1','4','10/21/10' UNION ALLSELECT '1','2','10/22/10' UNION ALLSELECT '1','1','10/23/10' UNION ALLSELECT '1','12','10/24/10' UNION ALLSELECT '1','11','10/25/10' UNION ALLSELECT '2','45','10/20/10' UNION ALLSELECT '2','34','10/21/10' UNION ALLSELECT '2','23','10/22/10' UNION ALLSELECT '2','20','10/23/10' UNION ALLSELECT '2','17','10/24/10' UNION ALLSELECT '2','18','10/25/10' UNION ALLSELECT '3','12','10/20/10' UNION ALLSELECT '3','23','10/21/10' UNION ALLSELECT '3','14','10/22/10' UNION ALLSELECT '3','12','10/23/10' UNION ALLSELECT '3','11','10/24/10' UNION ALLSELECT '3','3','10/25/10' UNION ALLSELECT '4','12','10/20/10' UNION ALLSELECT '4','3','10/21/10' UNION ALLSELECT '4','45','10/22/10' UNION ALLSELECT '4','56','10/23/10' UNION ALLSELECT '4','23','10/24/10' UNION ALLSELECT '4','3','10/25/10' SELECT * FROM MobileCustomers[/CODE]What I need I have to select customers who have total usage minimum 16 Rs from last 3 days they are being selected for some offer.But condition is that if customer's usage is reach upto 16 today only then he will be select for the offer. and if customer's usage is not upto 16 and usage of yesterday is more than 16 it means he is already selected for the offer so he will not be selected for today.even his total usage is more than 16 in last three days.Please wait for expected output.Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
|