pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tlund79 <thomas.lund@eniro.no>
To: pgsql-sql@postgresql.org
Subject: Using variables in select
Date: Fri, 12 Aug 2011 04:05:37 -0700 (PDT)
Message-ID: <1313147137184-4692865.post@n5.nabble.com> (raw)

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=<insert variable>

\\

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.



view thread (2+ messages)  latest in thread

Message-ID: <1313147137184-4692865.post@n5.nabble.com>
Permalink:  ../1313147137184-4692865.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1313147137184-4692865.post@n5.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: thomas.lund@eniro.no
  Subject: Re: Using variables in select
  In-Reply-To: <1313147137184-4692865.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox