Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL : How to formulate the query
Something like that:
v734> create table t (f1 number, f2 varchar2(4)); v734> insert into t values(1,'a'); v734> insert into t values(1,'c'); v734> insert into t values(2,'a'); v734> insert into t values(2,'b'); v734> insert into t values(3,'b'); v734> insert into t values(3,'c'); v734> insert into t values(4,'c'); v734> insert into t values(4,'a'); v734> commit; v734> select a.f2||' with '||b.f2||' = '||count(*) val2 from t b, t a
VAL
a with b = 1 a with c = 2 b with c = 1
3 rows selected.
--
Have a nice day
Michel
Chua Boon Yiang <chuaby_at_hotmail.com> a écrit dans le message :
824he2$rkg$1_at_newton3.pacific.net.sg...
> Hi
> presume i have these 2 fields in a table :
>
> F1 F2
> === ===
> 1 a
> 1 c
> 2 a
> 2 b
> 3 b
> 3 c
> 4 c
> 4 a
>
> I would like to get a stat of "how many with 'a' have 'b' or 'c' "
>
> eg
>
> a with b with
> b = 1 c = 1
> c = 2
>
> May i know how should i roughly come out with the SQL ?
>
> Thanks
> Boon Yiang
>
>
Received on Thu Dec 02 1999 - 04:00:14 CST
![]() |
![]() |