select b.*
from
(
select ROW_NUMBER() OVER (order by i.admit_date ) as rownum , i.hn,i.regist_flag,i.ladmit_n,
CAST(RTRIM(t.titleName) + RTRIM(p.firstName) + ' ' + RTRIM(p.lastName) AS CHAR(50)) AS Name
,w.ward_id,w.ward_name,dbo.ymd2cbe(i.admit_date) as date,
dbo.nowage(p.birthDay,dbo.ce2ymd(getdate()))as age
from Ipd_h i
left join PATIENT p on (p.hn=i.hn)
left join Ward w on(w.ward_id = i.ward_id)
LEFT JOIN PTITLE t ON (p.titleCode = t.titleCode)
where i.ward_id = '841' and i.discharge_status='0' ) as b
where b.rownum between '10' and '20'
No comments:
Post a Comment