I need to choose top 3 most recnet orders for each individual using order_date.
i have been able to choose top 2 most recent using order_date. But then it becomes complicated down to top 3.
Please use only joins. i'm not familiar with more complicated methods.
Here is my code:
select individual_id, drop_date, response ,
cast(null as int(1)) as score
from #ACTIVITY_1
...
User Profile
Collapse
-
Select a Random Sample of Raws
I need to create a simple random sample of 20,000 out of 4,000,000. what is the statement?
I was told select top 20K would do this but i believe the select top XXX is based on a first ordered database???
Please help!
Thanks -
Thanks for your reply. To be more specific, The promo_date is always populated. However for each promo_date there might be an order_date or NOT.
Now, for each order_date (if populated) i have to come up with a cost. If the order_date is NULL I would like to sum all costs related to those promo_dates that do not fall withhin 3 months from any other (non-NULL) order_dates in the whole database. The way i explain might be a little confusing.... -
aggregate rows of one column for each row of another column
I have 3 columns: cost, promo_date, order_date.
If order_date is not blank:
for each order_date i need to sum all costs as long as order_date - promo_date is less than 3 months. i looked at case statement but i didn't get the result:
Cost1=
sum(case when promo_date>=dat eadd(dd,-91,order_date) then Cost else 0 end) .
If order_date IS blank:
sum all costs associated with...
No activity results to display
Show More
Leave a comment: