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.
| Author |
Topic |
|
DareDelSol
Starting Member
1 Post |
Posted - 2002-11-04 : 19:00:58
|
| I have two tables "currentorders" and "historyorders". How do I find the MAX (orderdate) of both tables combined (besides the current orders with todays date)? Meaning the greater of the two tables. and what would the syntax of this be to create a stored procedure? This would tell me when the last order was placed not including the current order where the results will be displayed. Thanks! |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-11-04 : 19:12:47
|
| Hi Next time, can you post some DDL (Create table scripts) and maybe even some example data ? Otherwise it's just a guess.But, at a guess.....Select orderid, max(orderdate)From ( select orderid, orderdate from currentorders UNION ALL select orderid, orderdate from historyorders) ordersWhere orderid <> @CurrentOrder and DateDiff(d, orderdate, GetDate()) <> 0Group by orderidHope that helps. As for stored proc syntax, look up Create Procedure in Books OnlineDamian |
 |
|
|
|
|
|