私はクエリ全体を実行しています。最後にエラー(タイトル)が出て、出力が下のExcelイメージのようになるまで、すべて正常に動作します。私はcharとnumとdateとして時間を保持しようとしましたが、まだエラーが発生しています。どんな助けもありがとう。お気軽に質問し、ツール内のコードを確認してください。おかげOracle SQL - 時間は0から23の間の誤差でなければなりません
with ht as(
select labno, birthdt, spectype,
--to_char(
((dtrecv - dtcoll)
+ (to_date(nvl(tmrecv, '0000'), 'hh24mi')
- to_date(nvl(tmcoll, '0000'), 'hh24mi'))
) * 24
--, 'hh24:mi')
as hours
from azmsds.sample_demog_view
where tmrecv is not null and tmcoll is not null and dtrecv is not null and dtcoll is not null
),
secondQuery AS (
select
ht.hours,
extract(year from ht.birthdt) as "YEAR",
extract (month from ht.birthdt) as "MONTH",
count(distinct ht.labno) as "initialDbsReceiptCount<1",
'~' AS EOL
from ht
where 1=1
and ht.hours is not null
--and month not null
AND ht.birthdt >= '01-JAN-12'
-- and hours <= 23
and ht.spectype in (1,5,7)
--and hours > 23
group by extract(year from ht.birthdt), extract (month from ht.birthdt), ht.hours
order by extract(year from ht.birthdt) desc
),
ThirdQuery AS (
SELECT
sq.year,
sq.month,
sq."initialDbsReceiptCount<1",
sq.eol
FROM secondQuery sq
WHERE 1=1
--AND sq.hours <= 24
)
select * from ThirdQuery