Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id B3B74B5DBEA for ; Fri, 12 Aug 2011 08:20:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 28472-02 for ; Fri, 12 Aug 2011 11:20:43 +0000 (UTC) X-Greylist: delayed 00:15:05.529285 by SQLgrey-1.7.6 Received: from sam.nabble.com (sam.nabble.com [216.139.236.26]) by mail.postgresql.org (Postfix) with ESMTP id 697DCB5DBDC for ; Fri, 12 Aug 2011 08:20:43 -0300 (ADT) Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1QrpYX-0004bt-6N for pgsql-sql@postgresql.org; Fri, 12 Aug 2011 04:05:37 -0700 Date: Fri, 12 Aug 2011 04:05:37 -0700 (PDT) From: tlund79 To: pgsql-sql@postgresql.org Message-ID: <1313147137184-4692865.post@n5.nabble.com> Subject: Using variables in select MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.778 tagged_above=-5 required=5 tests=BAYES_00=-1.9, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201108/35 X-Sequence-Number: 35703 Hi, Firstly; I'm not a developer, but a business developer and statistics guy. This means that I'm happy using "basic" selects to gather information for analysis. One thing that could really efficiate my work is using variables, let's say I have a table with different orders; |customer_id|productid|price| What I really want is to create a general query where I could easily substitute productid. // declare variable --> productid = 10 select count(distinct customer_id), avg(price) from customer_table where productid= \\ Is there a way of doing this without getting involved with heavy programming? Thank you and applogies if this is a ridicioulus question! -- View this message in context: http://postgresql.1045698.n5.nabble.com/Using-variables-in-select-tp4692865p4692865.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com.