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

Home -> Community -> Usenet -> c.d.o.server -> Re: How do I count Columns in Different Tables??

Re: How do I count Columns in Different Tables??

From: Paul de Anguera <nospam_at_quidnunc.net>
Date: Fri, 10 Sep 1999 06:21:21 GMT
Message-ID: <7ra868$3t1$4@news.chatlink.com>


In article <7r93lc$ufj$1_at_nnrp1.deja.com>, stuco_at_mailcity.com wrote:
>Problem:
>
>I need to perform an aggregate count of columns in different tables
>that have relationships to each other. Here's how I envision it, but it
>is not working:
>
> SELECT COUNT(A.CUSTOMER_NO), COUNT(B.ITEMS_PURCHASED)
> FROM CUSTOMER A, SALES B
> WHERE A.DATE = '01-SEP-99'
> AND B.DATE = '01-SEP-99'
> /
>
>What I get is the same number on each count() every time, but in
>separate queries the number is different. Is there anyway to accomplish
>this with one query?

How about this?

SELECT "Customers:", COUNT(*) FROM CUSTOMER WHERE DATE = '01-SEPT-99'
UNION ALL
SELECT "Sales:", COUNT(*) FROM SALES
WHERE DATE = 'O1-SEPT-99'; You didn't say the result set had to be one row!

Paul de Anguera | "You can't write a chord ugly enough to say
Reply to:       | what you want to say sometimes, so you have to
deanguer@       | rely on a giraffe filled with whipped cream."
quidnunc.net    | - Frank Zappa
Received on Fri Sep 10 1999 - 01:21:21 CDT

Original text of this message

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