From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Willy-Bas Loos <willybas(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: test aggregate functions without a dummy table |
Date: | 2008-06-20 14:37:36 |
Message-ID: | 20080620143736.GA81866@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Jun 20, 2008 at 10:11:08AM -0400, Tom Lane wrote:
> "Willy-Bas Loos" <willybas(at)gmail(dot)com> writes:
> > I want to test the behavior of an an aggregate without creating a dummy
> > table for it.
> > But the code for it is horrible.
> > Is there no simpler way?
>
> > select max(foo)
> > from (select 1 as foo union select 2 as foo)bar;
>
> Perhaps VALUES?
>
> regression=# select max(foo) from (values(1,2),(3,4),(5,6)) as v(foo,bar);
Or perhaps using a set-returning function like generate_series():
test=> select max(foo) from generate_series(1, 100) as g(foo);
max
-----
100
(1 row)
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | Collin Peters | 2008-06-20 20:19:13 | Timezone issue - Is it me or is this a massive bug? |
Previous Message | Scott Marlowe | 2008-06-20 14:24:01 | Re: Connection to second database on server |