Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: 2 queries with one select :is it possible???
It's possible to obtain results from 2 queries in one result table
when you use UNION ALL (or UNION):
SELECT evt_code col1, TO_CHAR(evt_completed, 'mm') col2, COUNT(*) col3
FROM t1
WHERE evt_completed BETWEEN :begindate_param
AND :enddate_param AND status='C'
AND status='A'
GROUP BY evt_code, TO_CHAR(evt_target, 'mm');
gil guerillot <gil.guerillot_at_ratp.fr> wrote in message
news:9nnsfo$3va$1_at_gotix.reseau.ratp...
> i have 2 select queries with different 'where and group by clauses'
> i'd like only one select to obtain something like that: select
> evt_code,to_char(EVT_COMPLETED,'mm'),C1,C2.....
>
>
> Q1
> select evt_code,to_char(EVT_COMPLETED,'mm'),count(*) C1
> from T1
> where EVT_COMPLETED between :begindate_param and :enddate_param
> and status='C'
> group by EVT_code, to_char(EVT_COMPLETED,'mm')
>
> Q2
> select evt_code,to_char(EVT_target,'mm'),count(*) C2
> from T1
> where EVT_target < :begindate_param
> and status='A'
> group by EVT_code, to_char(EVT_target,'mm')
>
>
>
>
> is it possible with SQL?
>
>
Received on Thu Sep 13 2001 - 02:26:13 CDT