0

I'm attempting to add one to a column in a table for IDs that meet a certain criteria. Is there any way to do this without selecting that column for each ID?

Here is what I've attempted:

update AttendanceRecordReporting set Penalty8 = Penalty8 + 1 where ID = 
  (select ID from Employee where ID not in 
   (select distinct CWID from AttendanceRecord where RecordDate between 
    '3/1/2014 12:00:00 AM' and '6/1/2014 12:00:00 AM') and Department = 1)

The error I receive

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

1 Answer 1

3

USE 'IN' operator instead of '='

update AttendanceRecordReporting set Penalty8 = Penalty8 + 1 
      where ID IN 
           ( 
              select ID from Employee where ID not in 
                 (
                  select distinct CWID from AttendanceRecord where RecordDate between 
                 '3/1/2014 12:00:00 AM' and '6/1/2014 12:00:00 AM'
                  ) 
             and Department = 1
           )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.