SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old May 9th, 2008, 06:05 AM
elenton elenton is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 273 elenton User rank is Corporal (100 - 500 Reputation Level)elenton User rank is Corporal (100 - 500 Reputation Level)elenton User rank is Corporal (100 - 500 Reputation Level)elenton User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 13 h 14 m 3 sec
Reputation Power: 6
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"))

Reply With Quote
  #2  
Old May 9th, 2008, 10:18 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,025 sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 4 h 38 m 59 sec
Reputation Power: 608
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') 

Reply With Quote
  #3  
Old May 15th, 2008, 07:23 AM
elenton elenton is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 273 elenton User rank is Corporal (100 - 500 Reputation Level)elenton User rank is Corporal (100 - 500 Reputation Level)elenton User rank is Corporal (100 - 500 Reputation Level)elenton User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 13 h 14 m 3 sec
Reputation Power: 6
sorry for late response, that worked grat thanks for the help

Reply With Quote
  #4  
Old May 15th, 2008, 11:25 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,025 sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 4 h 38 m 59 sec
Reputation Power: 608
Quote:
Originally Posted by elenton
sorry for late response, that worked grat thanks for the help

You're welcome, glad it helped!!

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Update using max


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway