RE: Iterations in a SELECT

Поиск
Список
Период
Сортировка
От Scott Muir
Тема RE: Iterations in a SELECT
Дата
Msg-id NCBBKLMCJOGCLFHOFECNAECGDPAA.wsmuir@islandnet.com
обсуждение исходный текст
Ответ на RE: Iterations in a SELECT  ("Robby Slaughter" <webmaster@robbyslaughter.com>)
Ответы RE: Iterations in a SELECT  (Helge Bahmann <bahmann@math.tu-freiberg.de>)
Список 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@robbyslaughter.com]
Sent: July 17, 2001 8:39 PM
To: Scott Muir; pgsql-novice@postgresql.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




В списке pgsql-novice по дате отправления:

Предыдущее
От: "Robby Slaughter"
Дата:
Сообщение: RE: Iterations in a SELECT
Следующее
От: Helge Bahmann
Дата:
Сообщение: RE: Iterations in a SELECT