Gossamer Forum
Home : General : Databases and SQL :

Need query help

Quote Reply
Need query help
I am having problems writing a query and need help. Table name is maindb, I have a field named hh_num that is assigned a unique number if the address field is unique. So if there are two records with the same address, they will both have the same hh_num. I need to get a total number of records that are Individuals (unique hh_num) and a total of Households (count of hh_nums with multiple matches)

Any help is appreciated.

RG
Quote Reply
Re: [txsan] Need query help In reply to
In Reply To:
I am having problems writing a query and need help. Table name is maindb, I have a field named hh_num that is assigned a unique number if the address field is unique. So if there are two records with the same address, they will both have the same hh_num. I need to get a total number of records that are Individuals (unique hh_num) and a total of Households (count of hh_nums with multiple matches)

Any help is appreciated.

RG


These are the queries I've tried :

SELECT Count(*) FROM (SELECT count(*) from MAINDB GROUP BY HH_NUM HAVING count(*)=1) -- For count of Unique HH_num

SELECT Count(*) FROM (SELECT count(*) from MAINDB GROUP BY HH_NUM HAVING count(*)>1) -- For count of HH_num with multiple


But I get a syntax error near ')' .

Last edited by:

txsan: Jan 9, 2003, 7:06 AM