Reputation: 17
i used this query in sql server 2008 to select number of rows from large number
(select *
from (select *,
row_number() over (partition by
[Patient Family registration no# رقم الملف] order by ((CONVERT(date,[date of visit] ) ))) as seqnum
from MFC
) t
where seqnum = 1)
now i need to update column call (type of visit) to be 'new visit' for these rows that i selected, how can i do that?? thanks
Upvotes: 0
Views: 28
Reputation: 1269803
You can use an updatable CTE:
with toupdate as (
select mfc.*,
row_number() over (partition by [Patient Family registration no# رقم الملف]
order by CONVERT(date, [date of visit] )
) as seqnum
from MFC
)
update toupdate
set TypeOfVisit = 'New Visit'
where seqnum = 1;
Upvotes: 2