Failing Query
From: The Magnet <art_at_unsu.com>
Date: Wed, 13 Apr 2011 08:39:10 -0700 (PDT)
Message-ID: <d0616f88-c325-41ca-87e8-cf3746f3e0c8_at_z37g2000vbl.googlegroups.com>
Hi,
Date: Wed, 13 Apr 2011 08:39:10 -0700 (PDT)
Message-ID: <d0616f88-c325-41ca-87e8-cf3746f3e0c8_at_z37g2000vbl.googlegroups.com>
Hi,
I posted something similar to this elsewhere, but maybe a simpler example will help.
Why is this failing? In this query, the top query does have a matching criteria, the bottom does not. So, why does the entire query fail? What I thought it should do is return 2 columns, one with a value and the other NULL. Why does it return nothing? Really, these are separate subqueries, but why does everything fail is one of the subqueries return no results?
SELECT trial_status, paid_status
FROM (SELECT trial_status
FROM (SELECT order_date, co.status trial_status, ROW_NUMBER() OVER (ORDER BY order_date DESC) rnum
FROM customer_order_vw co, newsletter_subscription ns WHERE customer_id = 931044855 AND subproduct_id = 197 AND co.code = ns.code AND subscr_type = 'Trial') WHERE rnum = 1), (SELECT paid_status FROM (SELECT order_date, co.status paid_status, ROW_NUMBER() OVER (ORDER BY order_date DESC) rnum FROM customer_order_vw co, newsletter_subscription ns WHERE customer_id = 732126295 AND subproduct_id = 197 AND co.code = ns.code AND subscr_type <> 'Trial') WHERE rnum = 1);Received on Wed Apr 13 2011 - 10:39:10 CDT