次のselectステートメントで列pa.NumberOfPages
を選択できるようにしたいと思います。dm_package pa
これどうやってするの?
ステートメント 1 を選択
SELECT
Case When IsPackage = 1 then 'DM, Package' else 'DM' end as FaxType,
FaxId, RequestDate, FaxedTo, FaxNumber, Status, ExtendedStatus, StatusDate,
UserName, IsPackage, DocumentId, -1 as PatientMedicationId, '' as Event,
'-1' as NCPDPID, 0 as IsEPerscription, -1 as AccessionNumber,
Case When IsPackage = 0 then
(Select FilePath from PatientDocument where DocumentId = fl.DocumentId and ( '443' = -1 or '443' = PatientId ))
else (Select FilePath from dm_Package where fl.DocumentId = PackageId and ( '443' = -1 or '443' = PatientId )) End as Path,
Case When IsPackage = 0 then
(Select LastFirstName from Patient p, PatientDocument pd where fl.DocumentId = pd.DocumentId and pd.PatientId = p.PatientId)
else (select LastFirstName from Patient p, dm_Package pa where fl.DocumentId = pa.PackageId and pa.PatientId = p.PatientId) END as LastFirstName,
Case When IsPackage = 0 then
(select [Description] from PatientDocument where fl.DocumentId = DocumentId and ( '443' = -1 or '443' = PatientId ))
else (select PackageName from dm_Package where fl.DocumentId = PackageId and ( '443' = -1 or '443' = PatientId )) End as [Description],
'' as JobId, -1 as SeqNumber, '' as RefNumber, (select DocId from dbo.PatientDocument pd where fl.DocumentId = pd.DocumentId) as DocId
FROM dbo.dm_FaxLog fl
テーブル名dm_package pa
pa.IsFax, pa.FaxName, pa.faxNumber, pa.FilePath, pa.DocRoot, pa.Note, pa.PatientId,
isnull(fl.ExtendedStatus,'') as FaxExtendedStatus, StatusDate as FaxStatusDate, pa.DocId, pa.NumberOfPages