Solved

Help Needed With Query

Posted on 2015-01-17
5
55 Views
Last Modified: 2015-01-20
I need help with one more Query and then I'm done.  For this one, I need to update the SinceLastAssigned value for every participant who has a value of zero to the MAX value in that column, plus one (in the case of the data presented, that would be 176).  Please let me know if you have any questions.  Appreciate the help!

Sample Data
0
Comment
Question by:penlandt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 40556036
Is 176 the value for all rows having a zero?
0
 
LVL 1

Author Comment

by:penlandt
ID: 40556248
Yes, that's correct.   I'm assuming that this can be done in one query but the first part (of course) has to be identifying the maximum value in the since last assigned column, then updating all the rows where the value is 0 to that maximum value plus one.  Hope that helps.
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40556285
That's easy. If you would need unique values, that's getting difficult ;-).
update  tbl set sinceLastAssigned = nextMaxAssigned
from (select max(sinceLastAssigned)+1 as nextMaxAssigned from tbl) m
where sinceLastAssigned = 0

Open in new window

0
 
LVL 15

Expert Comment

by:Vikas Garg
ID: 40557191
Hi,

I agree with Qlemo,

You can Update
Update Tbl set sinceLastAssigned = (SELECT max(sinceLastAssigned) from Tbl)  +1
WHERE sinceLastAssigned = 0

Open in new window

0
 
LVL 1

Author Closing Comment

by:penlandt
ID: 40561404
Thank you very much, this was exactly what I needed!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question