Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How do I count Columns in Different Tables??
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 ZappaReceived on Fri Sep 10 1999 - 01:21:21 CDT
![]() |
![]() |