Re: [GENERAL] combine SQL SELECT statements into one

2010-02-01 Thread Chris . Ellis
> > -Original Message- > > From: chris.el...@shropshire.gov.uk > > [mailto:chris.el...@shropshire.gov.uk] > > Sent: Monday, February 01, 2010 4:08 AM > > To: neilst...@yahoo.com > > Cc: pgsql-general@postgresql.org > > Subject: Re: combine SQL SELECT statements into one > > > > > > Hi

Re: [GENERAL] combine SQL SELECT statements into one

2010-02-01 Thread Scott Marlowe
On Mon, Feb 1, 2010 at 12:09 PM, Igor Neyman wrote: > Original poster asked for the sql that will touch inventory table only > once. > > Your statement (with 3 subqueries) will do it 3 times. I'm pretty sure that starting with 8.3 the engine will collapse all those into one seq scan internally.

Re: [GENERAL] combine SQL SELECT statements into one

2010-02-01 Thread Igor Neyman
> -Original Message- > From: chris.el...@shropshire.gov.uk > [mailto:chris.el...@shropshire.gov.uk] > Sent: Monday, February 01, 2010 4:08 AM > To: neilst...@yahoo.com > Cc: pgsql-general@postgresql.org > Subject: Re: combine SQL SELECT statements into one > > > Hi > > pgsql-genera

Re: [GENERAL] combine SQL SELECT statements into one

2010-02-01 Thread Sam Mason
On Sun, Jan 31, 2010 at 11:36:55PM -0800, Neil Stlyz wrote: > SELECT COUNT(distinct model) FROM inventory WHERE modified >= '2010-02-01'; > SELECT COUNT(distinct model) FROM inventory WHERE modified >= '2010-01-20'; > SELECT COUNT(distinct model) FROM inventory WHERE modified >= '2010-01-01'; > > A

Re: [GENERAL] combine SQL SELECT statements into one

2010-02-01 Thread Chris . Ellis
Hi pgsql-general-ow...@postgresql.org wrote on 02/01/2010 07:36:55 AM: > Good Evening, Good Morning Wherever you are whenever you may be reading this. > > snip > > count1 | count2 | count3 > --- > 2 2 4 > > Can this be done wi

Re: [GENERAL] combine SQL SELECT statements into one

2010-02-01 Thread Florent THOMAS
Hi, If I were you, I worked like this. First make a union of those three query Then make a crosstab : http://www.postgresonline.com/journal/index.php?/archives/14-CrossTab-Queries-in-PostgreSQL-using-tablefunc-contrib.html documented here : http://www.postgresql.org/docs/8.4/interactive/tablefunc

[GENERAL] combine SQL SELECT statements into one

2010-02-01 Thread Neil Stlyz
Good Evening, Good Morning Wherever you are whenever you may be reading this. I am new to this email group and have some good experience with SQL and PostgreSQL database. I am currently working on a PHP / PostgreSQL project and I came upon something I could not figure out in SQL. I was wonderi