select FacName,rxs.FacID,rxs.PatID, rxs.rxno,rxs.PhNPI,PhName,NsID,Room,patients.PatFName,patients.PatLName,rxs.DrugLabelName,sig,
CardIDNo
, InsName
,errors.SeqNo
,errors.RejectCd
,errors.Submitted
,"ECSRejectCds"."Description"
,ECSRejectCds.ECSRejectCd
--
from Rxs
left join Facilities on rxs.FacID = Facilities.FacID
left join Patients on rxs.PatID = patients.PatID
left join vw_crystal_ReorderDirectionsExpandedSig vw on rxs.FacID = vw.FacID and rxs.RoNo = vw.RoNo and rxs.PatID = vw.PatID
left join PatientMOPs on rxs.PatID = PatientMOPs .PatID and rxs.FacID = PatientMOPs.FacID and rxs.MOP = PatientMOPs.InsID
left join InsPlans on rxs.MOP = insplans.InsID
left join ECSHistoryErrors errors on rxs.FacID = errors.FacID and rxs.PatID = errors.PatID and rxs.RxNo = errors.RxNo
left JOIN "FwReports"."dbo"."ECSRejectCds" "ECSRejectCds" ON errors."RejectCd"="ECSRejectCds"."ECSRejectCd"
where "Rxs"."RxBatch"='TP-RPH'
and CardIDNo is not null
and ECSRejectCds.Ver='D.0'
and rxs.FacID in('261','262','40')
order by Submitted desc ,SeqNo desc
ASKER
ASKER
ASKER
Microsoft SQL Server 2008 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. Major improvements include the Always On technologies and support for unstructured data types.
TRUSTED BY
This returns just the first row from whatever query you use.