From: | Ferruccio Zamuner <nonsolosoft(at)diff(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | To having or not to having? |
Date: | 2011-10-23 21:12:46 |
Message-ID: | 4EA4834E.7030409@diff.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello,
I'm rusty with SQL and I've started to practice it again but I'm falling
on this issue.
The problem:
Extracting rows from 'b' table trapping min() of a calculated value
"days" on 'a' table and a parameter.
SELECT b.*,
$1::date-a.sincedate AS "days"
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$'
ORDER BY $1::date-a.sincedate ASC;
attached there is the full example, data, creates and inserts for it.
$1 can by any date (now() for example is good enough)
$2 is a time interval (10:00 in the example).
I thank you in advance for any answer.
Bye, \ferz
Attachment | Content-Type | Size |
---|---|---|
example.txt | text/plain | 10.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Ferruccio Zamuner | 2011-10-23 22:55:20 | Re: To having or not to having? |
Previous Message | Linos | 2011-10-22 17:14:05 | Re: advice on how to store variable attributes |