Welcome to Sign in | Help

Re: t-sql update sql server 2000

  •  02-17-2009, 2:20 PM

    Re: t-sql update sql server 2000

    Acum am observat şi chestia cu "aceeasi luna (si an) la DataInregistrare pe primele 2 inregistrari". În cazul acesta ar fi:

    UPDATE aaa SET Principal=0 
    WHERE DataInregistrare IN ( 
     SELECT TOP 2 DataInregistrare FROM aaa b 
     WHERE b.CodContract=aaa.CodContract 
     AND DATEDIFF(month, DataInregistrare, ( 
      SELECT MIN(DataInregistrare) FROM aaa c 
      WHERE c.CodContract=b.CodContract 
     ))=0 
     ORDER BY DataInregistrare 
    ) 

View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems