RE: Iterations in a SELECT

From: "Scott Muir" <wsmuir(at)islandnet(dot)com>
To: <webmaster(at)robbyslaughter(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: RE: Iterations in a SELECT
Date: 2001-07-18 02:49:36
Message-ID: NCBBKLMCJOGCLFHOFECNAECGDPAA.wsmuir@islandnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Thank you... Your suggestion is how I am doing it until a better suggestion
comes along, but without building a dynamic sql statement with many UNION
statements (read: mess), I can't think of how to build a non-table-driven
multi-row query result...

That is the main problem here....
Thanks for the prompt reply though, Robby.

Scott..
-----Original Message-----
From: Robby Slaughter [mailto:webmaster(at)robbyslaughter(dot)com]
Sent: July 17, 2001 8:39 PM
To: Scott Muir; pgsql-novice(at)postgresql(dot)org
Subject: RE: [NOVICE] Iterations in a SELECT

Scott,

>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...

Sounds like you are trying to find out what values are not in a list of
other values.
Here's my example which you can adapt (if it's what you're trying to do).
Two tables,
test and test2, each with an integer column called val and val2
respectively:

select * from test;
val
---
1
2
3
5
6
3

select * from test2;
val2
----
3
4

Then you do a quick subselect and...

select * from test where val not in ((select val2 from test2));

Result is:
val
-----
1
2
5
6

Is that what you're hoping to do?

I can't think of anyway to do a select and genrate a list from x to y.
Wow, that's a great one!

Hope this helps,

-Robby

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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Helge Bahmann 2001-07-18 03:05:11 RE: Iterations in a SELECT
Previous Message Robby Slaughter 2001-07-18 02:38:54 RE: Iterations in a SELECT