我有 2 个表..我正在将状态历史记录移动到一个表中并将其显示在另一个表中..第二个表获取最近的状态并将其显示在网页中
像这样我需要..但我越来越
我需要更新的记录以及空状态记录。我的查询是:
with ctr as
(
select en.status update,ed.no,row_number()
over (partition by ed.no order by en.update descending) as [RN],
ed.[conference date],ed.conference name,ed.region,ed.inquiry,
ed.attended by,ed.doctor name,ed.hospital,ed.contact no,ed.email, ed.adds,
CONVERT(VAR CHAR(10),en.[update], 103) as update,ed.closed,
CONVERT(VAR CHAR(10),ed.[closing date],103) as closing date,
ed.closed by, ed.revenue, ed.approve status, ed.Enid from inquiries_details ed
inner join
inquiries en on ed.Enid = en.Enid
inner join
staff_details SD on ed.region = SD.state
where region = 'Maharashtra'
)
select * from ctr where RN = 1
谁能帮我