WITH clause working in 10g but not in 11g (XE) [message #644969] |
Mon, 23 November 2015 00:18 |
|
Rishab_le_noob
Messages: 12 Registered: November 2015 Location: Kolkata
|
Junior Member |
|
|
Hi Friends,
I'm trying to get all the Fridays since Jan-2000 till today.
Now there can be two approaches as far as I know
a) Using a CONNECT BY with dual.
b) Using a Recursive query using WITH - I'm facing issues here.
Query using WITH
with dte (dat) as
(select sysdate dat from dual
union all
select dat-1 from dte where dat>to_date('Jan-01-2000','Mon-DD-YYYY'))
select to_char(dat,'DD-MM-YYYY Day') from dte where to_char(dat,'DY') in ('FRI');
Description: Get the current date using sysdate.
Run a recursive union on it inside WITH until the date is > my desired old date (which is Jan 2000 here).
Issue: This query works fine in 10g. But in 11g (XE edition) it gives me the error "ORA-01790: expression must have same datatype as corresponding expression"
As far as I'm guessing its cuz oracle doesnt recognize the Column alias "dat" as a date field. But am not sure.
Can anyone tell me why is this so?
Anyone with access to 11g full edition can you please try and tell if its cuz of the XE thing?
Thank You
Rishab
[Updated on: Mon, 23 November 2015 01:20] Report message to a moderator
|
|
|
|
|
|