Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SELECT query with "count"?

Author  Topic 

vickrr1z
Starting Member

1 Post

Posted - 2004-03-25 : 07:05:12
Hi, im using Postgresql [psql]

let say i have tables party_list_cocv, party_lit_orgs and municipalities:

in table party_list_cocv each municipality has complete of 162 party_list of votes, and there's some
others are incomplete or less than 162.. these was caused due from encoding phase.

i post this as sample of my query:
SELECT count(municipality_code) As total_rec FROM party_list_cocv INNER JOIN municipalities
USING (municipality_code) INNER JOIN party_list_orgs ON party_id = party_list
WHERE municipality_code = '980106000';
result gives:
total_rec
-------
159
(1 row)

now what i want to do is selecting all the records of municipality which was only a count
less than 161. i did this way but gives me error but i know its really not appropriate?
SELECT province_code, municipality_name count(municipality_code) As total_rec
FROM party_list_cocv INNER JOIN municipalities
USING (municipality_code) WHERE total_rec <= 161;
-----
the error: "ATTRIBUTE 'total_rec' not found

Does anyone know how I can do this? any suggestions would be greatly apreciated.

Thanks very much

Mabuhay!!!

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-03-25 : 07:56:57
For a start this is a MS$ SQL site...postgresql support is not quite our cup of tea.
however at a glance, you seem to missing a ',' between "municipality_name" and "count("
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2004-03-25 : 08:38:11
http://www.dbforums.com/f81/ will be a better place for your question, methinks.




--Frank
http://www.insidesql.de
Go to Top of Page
   

- Advertisement -