Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2012
    Posts
    16

    Unanswered: Pairwise Comparison in update statement like Oracle in SQL Server

    Hi I would like to know what can be the equivalent update command in SQL server?
    Code:
    update Table1 set EndFlag = 1 
      where (c1,c2) in (select c1, MAX(c2) from Table1 group by c1)

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    A CTE or subquery will work:
    Code:
    update	Table1 set EndFlag = 1
    from	Table1
    	inner join --Aggregates 
    		(select c1, MAX(c2) as Maxc2 from Table1 group by c1) as Aggregates
    		on Table1.c1 = Aggregates.c1
    		and Table1.c2 = Aggregates.Maxc2)
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jul 2012
    Posts
    16
    Great!
    Thanks a lot

Tags for this Thread

Posting Permissions

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