Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 292F79FB6A8 for ; Fri, 3 Aug 2007 03:29:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 45603-08 for ; Fri, 3 Aug 2007 03:29:12 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from rrmailscan3.safenetbox.biz (mailscan3.reynolds.com.au [203.25.40.75]) by postgresql.org (Postfix) with ESMTP id 95D039FB69E for ; Fri, 3 Aug 2007 03:29:09 -0300 (ADT) Received: from rrmailscan3.safenetbox.biz (rrmailscan3.safenetbox.biz [127.0.0.1]) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 51C981D4845C for ; Fri, 3 Aug 2007 15:36:01 +1000 (EST) Received: from [127.0.0.1] (online4-new.lnk.telstra.net [139.130.169.227]) (Authenticated sender: remote) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id F1E481D4843A for ; Fri, 3 Aug 2007 15:35:59 +1000 (EST) Message-ID: <46B2BE9E.8010202@autoledgers.com.au> Date: Fri, 03 Aug 2007 13:35:26 +0800 From: Paul Lambert User-Agent: Thunderbird 2.0.0.5 (Windows/20070716) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Count of rows Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/16 X-Sequence-Number: 28954 What's the best way to count how many rows are in each table via SQL? Or is it even possible? I'm trying something like: select tablename, count(*) from (select tablename from pg_tables where schemaname = 'public') as test group by tablename; But obviously this just gives a count of 1 for each table in the public schema. Can it be done or would I have to write a function? -- Paul Lambert Database Administrator AutoLedgers