Results 1 to 9 of 9

Thread: [RESOLVED] sql server aggregate query

Threaded View

  1. #5

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: sql server aggregate query

    So if this is my table being built:
    Code:
    GroupID	Status5RowId	CreateDateStatus5	Status6RowId	CreateDateStatus6
    43        95             NULL                        NULL                       NULL
    57        675            NULL                        NULL                       NULL
    I next want to update EnrollStatus6RowId with 676, because 676 is my max GroupStatusId of my 6 records. But I get an error that I can't do a MAX in a SET (An aggregate may not appear in the set list of an UPDATE statement):
    Code:
    	
    update @FinalStatus_5and6_RowID	
    set Status6RowId = MAX(groupstatusid)
    		from @FinalStatus_5and6_RowID A 
    		inner join GroupStatus B
    		on A.GroupID = B.GroupID
    		and B.StatusID = 6
    Last edited by si_the_geek; May 7th, 2013 at 12:58 PM. Reason: added tags to data
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width