Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Count?

Re: Count?

From: Dave Evans <devans_at_radius-retail.kom>
Date: Wed, 19 May 1999 11:24:18 +0100
Message-ID: <7hu6ib$5okt4@news.gomontana.com>


[mailed+posted]

Try:

SQL> select * from t1;

        ID T
---------- -----------------------------------------------------------------


         1 apple
         2 bat
         3 cat
         4 nothing

SQL> select * from t2;

        ID T
---------- -----------------------------------------------------------------


         1 apple juice
         2 apple cider
         3 apple
         4 bat
         5 baseball bat
         6 cat
         7 catwoman
         8 apple cat

8 rows selected.

SQL> select t1.id, t1.t, count(t2.id)
  2 from t1, t2
  3 where t2.t(+) like '%'||t1.t||'%'
  4 group by t1.id, t1.t
  5 /

        ID T
COUNT(T2.ID)
---------- -----------------------------------------------------------------

----------------------------------- ------------
         1 apple
4
         2 bat
2
         3 cat
3
         4 nothing

0

SQL> Leave out the outer join (the "(+)" characters) if you don't want the zeroes. Received on Wed May 19 1999 - 05:24:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US