RES as
(
SELECT code , payement,
sum(A.ALLPAYMENT) as ACTUAL_PAYMENT,
A.NAME
FROM FINANCES A
WHERE payement= '6396'
and (ENDDATE>= CURRENT_TIMESTAMP)
and (BILLREFRENCE<> '' or
(case when ( CONVERT (int, (select BILLTIME from MYCALENDAR CL
where CL.code = A.code and CL.NAME=
A.NAME
)
)
> CONVERT (INT, REPLACE( CONVERT(VARCHAR(8), GETDATE(), 108),
':', '' ) )
) then LEVEL in ('300', '100', '404')
else
LEVEL in ('300','404')
)
)
GROUP BY code, payement, A.NAME)
OR条件需要为“或('300’、'100’、'404’)中的级别”或
注:BILLTIME的格式是军事时间“130000”,因此需要转换。