[SQL] One-2-many relation - need distinct counts

2003-08-26 Thread PS PS
Hi gurus,

I have table A, B and need a distinct count of
Accounts from A.  There is a one-2-many relation
between A and B.  Accounts # in A are all unique. 
However, in B there will be duplicates.  So the
problem I have is, when I join as follows:
Select Count(Distinct(account_no)) 
from A, B 
where A.Account_no = B.Account_no

I get the correct count.  If I do this:
Select Count(Distinct(account_no)), B.Account_type 
from A, B 
where A.Account_no = B.Account_no 
group by B.Account_type

I get wrong counts because there some are duplicated. 
I tried everything that I can think of - subquery, sub
table etc.  I would appreciate some help in writing
the query.  Thanks in advance.

PS

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


[SQL] Max Columns in a SQL Select

2004-05-17 Thread PS PS
SQL Guru's,

Does anyone know what is the Column Limit in a SQL
Query in Oracle RDB version 7.1?  

I've about 200 columns in my SQL query.  Each column
is a computed column -- Case when a = b Then c Else 0
End.

It gives me a runtime error -- abnormal program
termination -- upon execution.  

Thanks a lot in advance.




__
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings