|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Update using max
Hi Im trying to write an update query but i cant get the unique id out so i need to update using the max service date.
Below currently gets all the properties, but i only want to update the one with the max service date as this will be the most recent one, how do i write an update with a max date? Code:
UPDATE dbo_tbl_service SET dbo_tbl_service.SERVICEDATE = "123" WHERE (((dbo_tbl_service.PROPREF)="1") AND ((dbo_tbl_service.CONTRACT)="dum")) |
|
#2
|
||||
|
||||
|
I'm not really sure of the syntax but I would suggest that you could use an IN query, something like this:
Code:
UPDATE dbo_tbl_service SET SERVICEDATE = '123' WHERE PROPREF = '1' AND CONTRACT = 'dum' AND SERVICEDATE IN(SELECT MAX(SERVICEDATE) FROM dbo_tbl_service WHERE PROPREF = '1') |
|
#3
|
|||
|
|||
|
sorry for late response, that worked grat thanks for the help
|
|
#4
|
||||
|
||||
|
Quote:
You're welcome, glad it helped!! |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Update using max |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|