From: Ferruccio Zamuner <nonsolosoft@diff.org>
To: pgsql-sql@postgresql.org
Subject: Re: To having or not to having?
Date: Mon, 24 Oct 2011 00:55:20 +0200
Message-ID: <4EA49B58.9040602@diff.org> (raw)
In-Reply-To: <4EA4834E.7030409@diff.org>
References: <4EA4834E.7030409@diff.org>
On 10/23/11 23:12, I wrote:
> Hello,
>
> I'm rusty with SQL and I've started to practice it again but I'm falling
> on this issue.
I've found first solution using WINDOWING:
SELECT d.pintime, d.a_id, d.c_id, d.value, d.id, d.sincedate,
d.todate, d.description, d.genre
FROM (SELECT pintime,a_id,c_id,value,id,sincedate,todate,description,
genre, $1::date-a.sincedate as days, min($1::date-a.sincedate) over w AS
"days 2"
FROM b, a
WHERE pintime BETWEEN $2 AND $2::interval+'00:01:00'::interval
AND b.a_id=a.id AND a.genre='F' AND description ~*'35$'
WINDOW W AS (partition by c_id)
ORDER BY $1::date-a.sincedate ASC) AS d
WHERE d.days=d."days 2"
ORDER BY d.c_id;
I'm sure that there are many other solutions and probably mine could be
not the best. So I'm looking for more hint and suggestions.
Thank you again. \ferz
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: nonsolosoft@diff.org
Subject: Re: To having or not to having?
In-Reply-To: <4EA49B58.9040602@diff.org>
* 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