Hello,
I have a query as follows.
------------------------------------------------
with base as
(
select date, cust_id, amount
from multiple tables
union all
select date, cust_id, amount
from multiple tables
)
select * from base
where snapshot_date = '31-jul-2014'
-------------------------------------------------
This query takes too long. If I throw in "where snapshot_date = '31-jul-2014'" for both selects within the "with-clause", it is really fast.
It seems the with-clause is creating a view with all the snapshots, rather than just 31-jul-2014. Is there a way to force the "with-clause" to retrieve data for only snapshot_date = '31-jul-2014'as specified in the main query above without using the where clause inside "with-clause"?
Thanks very much all...
I have a query as follows.
------------------------------------------------
with base as
(
select date, cust_id, amount
from multiple tables
union all
select date, cust_id, amount
from multiple tables
)
select * from base
where snapshot_date = '31-jul-2014'
-------------------------------------------------
This query takes too long. If I throw in "where snapshot_date = '31-jul-2014'" for both selects within the "with-clause", it is really fast.
It seems the with-clause is creating a view with all the snapshots, rather than just 31-jul-2014. Is there a way to force the "with-clause" to retrieve data for only snapshot_date = '31-jul-2014'as specified in the main query above without using the where clause inside "with-clause"?
Thanks very much all...