Re: Returning number of values from sub-query
Date: Mon, 21 Jan 2008 16:20:16 -0800 (PST)
Message-ID: <5b39f7dc-a131-4f4e-96b6-8c6c74749ea7@i72g2000hsd.googlegroups.com>
On Jan 21, 3:16 pm, trp..._at_gmail.com wrote:
> I have the following query that returns 1 row:
>
> SELECT REPORT_DATE, STARTS FROM SUBSCRIPTIONSUMMARYDATA WHERE
> REPORT_DATE IN (TO_DATE('01/20/2008','MM/DD/YYYY'),
> TO_DATE('01/21/2008','MM/DD/YYYY'))
>
> REPORT_DATE STARTS
> 01/20/2008 100
>
> What I am afer is to have 2 rows returned based on the values in the
> subquery, so I really want results like this:
>
> REPORT_DATE STARTS
> 01/20/2008 100
> 01/21/2008
>
> So I want 1 row returned for each row of the subquery. Any ideas, or
> how can I accomplish ths better.
Your example code doesn't have a subquery, so you can't. If you really had a subquery that returns the dates you want to see, you could use an outer join:
SELECT subquery.REPORT_DATE, t.STARTS
FROM SUBSCRIPTIONSUMMARYDATA t
right outer join
(select TO_DATE('01/20/2008','MM/DD/YYYY') report_date from dual
union all
select TO_DATE('01/21/2008','MM/DD/YYYY') report_date from dual
) subquery
on t.report_date = subquery.report_date
Received on Mon Jan 21 2008 - 18:20:16 CST