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 |
|
Looper
Yak Posting Veteran
68 Posts |
Posted - 2009-10-28 : 11:55:51
|
I have a table that holds a list of car leases for a user. A user can have multiplecar leases with start and end dates. What I want is a sql query that will set the lease end date to the current date for the recordthat has the latest start date only. so if a user had two rows in this table I only want to update the row with the start date that is the latest. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-28 : 12:03:18
|
Something like this:update car_leasesset lease_end_date = getdate()where userid = wanted_useridand lease_start_date=(select max(lease_start_date) from car_leases where userid=wanted_userid) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|