Skip site navigation (1) Skip section navigation (2)

RE: Iterations in a SELECT

From: "tamsin" <tg_mail(at)bryncadfan(dot)co(dot)uk>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: RE: Iterations in a SELECT
Date: 2001-07-18 08:17:39
Message-ID: NEBBKHBOBMJCHDMGKCNJIEDGDBAA.tg_mail@bryncadfan.co.uk (view raw or flat)
Thread:
Lists: pgsql-novice
how about using BETWEEN?

select * from tablename where datefield between '2001-01-01' and
'2001-05-05';

or if you're looking for dates outside the period

select * from tablename where datefield NOT between '2001-01-01' and
'2001-05-05';

(i'm assuming your list of dates has no gaps in it, could be wrong!)

hth,
tamsin



-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Scott Muir
Sent: 18 July 2001 03:08
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] Iterations in a SELECT


I have a small problem which I'm looking for an elegant solution to...

I'm trying to put together a select where a list dates is compared to a
period to identify dates which aren't in the list...

I could just create a list of days in a table (like 20 years worth) and then
compare it, but I'm wondering if there is a trick where one could get
results like this

select (for i := 1 to 5) as number;

or

select i as number from for(i,1,5);

and get something like

number
------
1
2
3
4
5

Any suggestions?
Thanks
Scott.


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html


In response to

pgsql-novice by date

Next:From: Leandro FanzoneDate: 2001-07-18 12:25:07
Subject: ANSI SQL
Previous:From: Helge BahmannDate: 2001-07-18 03:05:11
Subject: RE: Iterations in a SELECT

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group