thanks for taking the time to help me out! I’m trying to make SQL do something that I imagine is easy for anybody who knows SQL, but I’m beating my head against at this point.
I have me a little table like this –
Update Order UpdateDate OrderDate
9297 3590 2012-12-06 2012-12-06
9298 3590 2012-12-06 2012-12-06
9356 3590 2012-12-07 2012-12-06
9369 3590 2012-12-08 2012-12-06
9381 3590 2012-12-10 2012-12-06
My goal is to find orders that have not been updated in the last 3 days.
The ugly version of what I’m trying to do is something like this –
Select order from orderstable
where cast(max(updatedate)-getdate() as int) >3
The goal here is to have the command return “orders” that have not been updated in the last 3 days. My current problem is I don’t know how to make SQL focus on just the “most recent” updatedate for the order.
The easiest way is just a date comparison:
I see, you have multiple records for each order and you want orders that have no update in the past three days. I would do this with an aggregation:
You can also do it by looking for orders that don’t have updates in the last three days: