Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

lead() error

hemant_kMar 12 2024 — edited Mar 12 2024

hi I am trying to deduct a date from another date

but getting error as ORA-00932: inconsistent datatypes: expected NUMBER got DATE

my query is as below

select sol_id,tran_date_bal*to_number(next_date-eod_date), next_date-eod_date days from (
select a.sol_id,a.bacid,b.eod_date,b.tran_date_bal,
lead(b.eod_date,1,b.eod_date) over (partition by a.sol_id,a.acid order by b.eod_date) next_date,
(case when lead(b.eod_date,1,b.eod_date) over (partition by a.sol_id,a.acid order by b.eod_date)-b.eod_date=0 then 1
else lead(b.eod_date,1,b.eod_date) over (partition by a.sol_id,a.acid order by b.eod_date)-b.eod_date end) dayx,
rank() over (partition by a.acid,a.sol_id order by b.eod_date desc) rnk
from gx a inner join gx b on a.acid=b.acid
where b.eod_date <='01-apr-2023'
and a.BACID IN (
'19007001','19007002','19008001','19008002',
'19008004','19008005','19008003','19009001',
'19010001','19010002','19011002','19012001',
'19013001','19014001')
) where rnk=1

gx.sql

fx.sql

This post has been answered by Frank Kulash on Mar 12 2024
Jump to Answer
Comments
Post Details
Added on Mar 12 2024
5 comments
291 views