「Patient Days」または同じ日に退院する患者(csn_id)を追跡しているクエリがあります。これは2つの方法のいずれか MS-SQLの列の無効なエラー
- 認めると私は文で私のグループを追加するまで、6
すべてが良い見えたイベントタイプと1
group by
を行うと SELECT
'1,*'+char(13)+char(10)
+'80,1006057'+char(13)+char(10)
+'100,10'+char(13)+char(10)
+'2405,'+cast(count(distinct adt.PAT_ENC_CSN_ID) as varchar(18))+char(13)+char(10) --Census events --as varchar(10)
+'2420,'+format(adt.EFFECTIVE_TIME,'M/d/yyyy') --as efftime
FROM CLARITY_ADT adt
inner join PAT_ENC_HSP hsp on adt.PAT_ENC_CSN_ID=hsp.PAT_ENC_CSN_ID
WHERE adt.EVENT_SUBTYPE_C <>2 AND --no canelled events
datediff(day,adt.EFFECTIVE_TIME,cast(CURRENT_TIMESTAMP as date)) between 1 and 7 AND
((adt.EVENT_TYPE_C ='6' AND
adt.DEPARTMENT_ID in ('101000020', '101000021', '101000013', '101000014', '101000002',
'101000018', '101000003', '101000114', '101000005', '101000017',
'101000006', '101000118', '101000007', '101000016', '101000004',
'101000009', '101000010', '101000011', '101000022', '101000023',
'101000012')) OR
(cast(hsp.HOSP_ADMSN_TIME as date) = cast(hsp.HOSP_DISCH_TIME as date) AND
adt.EVENT_TYPE_C ='1' AND
adt.DEPARTMENT_ID in ('101000020', '101000021', '101000013', '101000014', '101000002',
'101000018', '101000003', '101000114', '101000005', '101000017',
'101000006', '101000118', '101000007', '101000016', '101000004',
'101000009', '101000010', '101000011', '101000022', '101000023',
'101000012')))
group by cast(adt.EFFECTIVE_TIME as date)
order by cast(adt.EFFECTIVE_TIME as date)
タイプは何ですかEFFECTIVE_TIME列の – Simon