Reputation: 18387
I'm facing a very weird problem where I have a complex (long) query with multiple CTE's and in the end I select values from those multiple CTE's using cross joins. Most of the time it works fine, but for some cases it's returning 0 zeros where it should return data.
Running the cte's individually I can see the data I'm looking for. Then I've started to add one cte at a time in the final cross join. I've noticed that for only one is "crashing" the results even though it's not throwing any error.
My final test, I've moved the problematic one as the first cte in my final select statement and everything is working fine (in the following query, imagine cte_e becomes the first one in the final select).
the query looks like this:
;with cte_a as
(
//select
),
cte_b as
(
//select
),
cte_c as
(
//select
),
cte_d as
(
//select
)
,
cte_e as
(
//select
)
select * from
cte_a,
cte_b,
cte_c,
cte_d,
cte_e
Questions:
Is there any constrain related to type of the data when using cross joins?
Is there any limit related to the number of CTEs in a query?
How can I proper identify what is the issue with this CTE in particular?
Upvotes: 0
Views: 158
Reputation: 18387
I've changed the way I'm returning the data, rather than cross join, one value per row and now it's working as expected. Thank you all for trying to help.
Upvotes: 0
Reputation: 6015
Upvotes: 1