Using variables in select

From: tlund79 <thomas(dot)lund(at)eniro(dot)no>
To: pgsql-sql(at)postgresql(dot)org
Subject: Using variables in select
Date: 2011-08-12 11:05:37
Message-ID: 1313147137184-4692865.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Oliveiros d'Azevedo Cristina 2011-08-12 16:03:52 Re: Using variables in select
Previous Message Don Parris 2011-08-11 21:21:23 Re: Stuck Up In My Own Category Tree