3
I have the script below in SQL Server, but I need to mount it in Oracle. I don’t know anything about Oracle and I couldn’t make it work. Could you help me? Oracle: 11.2.0.4.0
SQL script:
DECLARE @DataExec datetime
DECLARE @DataRef datetime
SET @DataExec = '20161008'
set @DataRef = '20101205'
Select datediff(dd, @DataExec, Max(DatBase)) as DiasDiferenca,
max(DatBase) as DataLimite,
count(1) as Qtde_Registros
from Tabela
where datbase <=@DataRef
Try Oracle Script:
VAR DataExec date
VAR DataRef date
Exec :DataExec := to_date('20161008','YYYYMMDD')
Exec :DataRef := to_date('20101205','YYYYMMDD')
Select (:DataExec - max(DATBASE)) as DiasDiferenca,
max(DATBASE) as DataLimite,
count(1) as Qtde_Registros
from DELQMST
where DATBASE <= :DataRef;
Error:
ORA-00932: inconsistent datatypes: expected CHAR got DATE
did not work: ORA-00900: invalid SQL statement SQL parse error Location
– Marcio
in the select Max I switched to select Max(datBase)
– Marcio