Appframe Knowledge Base


1 hits
1

Use CTE and ROW_NUMBER() to mark the først record in a given sortorder

WITH CTE
AS
(SELECT *,
ROW_NUMBER() OVER(Partition by PersonID ORDER BY StartDato) AS Ranking
FROM atbl_CRM_Medlemskap M
WHERE ISNULL(M.Avsluttet,GETDATE()+1) > '2011-12-30')

UPDATE CTE
SET Tellende=1, CUT=0
WHERE Ranking =1

sql · Perma link post comment Posted by: Sigmund Lunde (01-okt-2012)