Array
(
)

Conversão de Query SQL Oracle para Query SQL Server

Marcelo Silva
   - 17 mar 2016

Bom dia!
Estou com problemas na hora de converter uma query que roda em Oracle, rodar em SQL Server.
Alguém poderia me ajudar?
Segue a Query.
select TO_CHAR(DWH001.DWH001_DATE, 'MM') ORDEM,
TO_CHAR(DWH001.DWH001_DATE, 'MON') MES,
TO_CHAR(DWH001.DWH001_DATE, 'YYYY') ANO,
TRUNC(SUM(DWH001.DWH001_ACTIVE_ADMISSION_TOTAL) / (saidas_geral.qtd_saidas),2) TEMPO_MEDIO

from DWH001_ADT_UNIT_TOTAL DWH001,
(select TO_CHAR(adt021_discharge_date, 'MM/YYYY') PERIODO, count(*) QTD_SAIDAS
from adt021_discharge adt021
inner join adt001_admission adt001
on adt001.adt001_admission_id = adt021.adt001_admission_id
inner join sys002_unit sys002
on sys002.sys002_unit_id = adt001.sys002_unit_id
WHERE adt021.adt021_discharge_date BETWEEN TO_DATE('01-'||'01-2015','DD-MM-YYYY') AND last_day(TO_DATE('01-'||'03-2016','DD-MM-YYYY')) --INSERIR FILTRO
and adt001.adt043_admission_regimen_id <> 6 --EXCETO HOSPITAL DIA (12H)
Group by TO_CHAR(adt021_discharge_date, 'MM/YYYY')) SAIDAS_GERAL,
SYS002_UNIT SYS002
WHERE DWH001.DWH001_DATE BETWEEN TO_DATE('01-'||'01-2015','DD-MM-YYYY') AND last_day(TO_DATE('01-'||'03-2016','DD-MM-YYYY')) --INSERIR FILTRO
and sys002.sys002_unit_id = dwh001.sys002_unit_id
and saidas_geral.PERIODO = TO_CHAR(DWH001.DWH001_DATE, 'MM/YYYY')
group by TO_CHAR(DWH001.DWH001_DATE, 'MM'),
TO_CHAR(DWH001.DWH001_DATE, 'MON'),
TO_CHAR(DWH001.DWH001_DATE, 'YYYY'),
SAIDAS_GERAL.QTD_SAIDAS
ORDER BY TO_CHAR(DWH001.DWH001_DATE, 'YYYY'),
TO_CHAR(DWH001.DWH001_DATE, 'MM')