Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A964A6349FA for ; Wed, 18 Nov 2009 13:08:14 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 82105-07 for ; Wed, 18 Nov 2009 17:08:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.223.182]) by mail.postgresql.org (Postfix) with ESMTP id 24547633F67 for ; Wed, 18 Nov 2009 13:07:59 -0400 (AST) Received: by iwn12 with SMTP id 12so972369iwn.15 for ; Wed, 18 Nov 2009 09:07:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=KDzIxEYjsFp77nPK5JHeduF90OSAOhI0xHjlgDwcdwY=; b=ISeVrw+hafo/aT23CTfJvS2XCRYp87YTogeqdSytJHVCiUfwPBOzZgWlOdp19nMq7a WA7jCKX4+4mozPmrHt52ewFKZ58fvUr7UH9tsI4frsrTe6oX20JNbzOIh5yqb9ROUOLr +8PbrJbeyAgMkvKtsv7TP+XSxXyS4jbaXi+qo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=o7Pz43tdXlW42FPpo0vZMNsfpsjbsBan47u+Uff1SOXsQUIpCYEvFKl+5312VBI+Qi J1qy6phUPcB6D7ykxvdncfaHj1QUm2yqt6niDVGvzUOCHSPXeTq0zhyhNjX1xVUXlDL4 XPd/nWiRI4GDtDxlcSE48AEFQaN29mqWqxgUU= MIME-Version: 1.0 Received: by 10.231.168.131 with SMTP id u3mr1950232iby.26.1258564079168; Wed, 18 Nov 2009 09:07:59 -0800 (PST) In-Reply-To: References: Date: Wed, 18 Nov 2009 10:07:59 -0700 Message-ID: Subject: Re: need nelp with aggregate functions From: Scott Marlowe To: Another Trad Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200911/46 X-Sequence-Number: 33397 On Wed, Nov 18, 2009 at 9:55 AM, Another Trad wrote: > The DB structure is in attachment. > I with the number of clients and the number of computers that have > processors with "manufacturer" = "INTEL" and "speed" = "2GB" > I am trying: > > select count(c) as qtd_client, count(cm) as qtd_computers > > from cliente c > inner JOIN computer cm on (c.cliente_id = cm.cliente_id) > inner join processor p on (cm.processor_id = p.processor_id) > inner join speed s on (s.speed_id = p.speed_id) > INNER JOIN manufacturer m on (p.manufacturer_id=m.manufacturer_id) > > where m.manufacturer = 'INTEL' > and s.speed = '2GB' > > but is not working > anyone can help me? If you are getting an error message it's a good idea to post it as well. However, first problem is that c and cm are tables, not fields. You need to count some field from those tables.