Re: Date

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: Date
Дата
Msg-id 20061229072406.GA13834@a-kretschmer.de
обсуждение исходный текст
Ответ на Date  ("ice" <iceruam@gmail.com>)
Список pgsql-general
am  Thu, dem 28.12.2006, um  7:24:30 -0800 mailte ice folgendes:
> Hello,
>    I have a couple of tables.  The client tables and the contacted
> tables.
> I am not sure how to start on this, what I need is a way to query  all
> my clients
> then show any client that the last visit  and or called day is greater
> than 30 days.

You are searching for the CASE-statement, a simple example:

test=# select * from visits;
 id |  typ   |   datum
----+--------+------------
  1 | visit  | 2006-01-01
  2 | visit  | 2006-02-01
  3 | called | 2006-03-01
  4 | called | 2006-05-01
  5 | called | 2006-11-01
  6 | visit  | 2006-11-02
  7 | visit  | 2006-12-02
  8 | called | 2006-12-03
(8 rows)

test=# select case when typ='visit' then datum else null end as visit,
  case when typ='called' then datum else null end as called
  from visits
  where datum > current_date-60;
   visit    |   called
------------+------------
            | 2006-11-01
 2006-11-02 |
 2006-12-02 |
            | 2006-12-03
(4 rows)





Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47215,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

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

Предыдущее
От: Ben
Дата:
Сообщение: Re: Geographical redundancy
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: LDAP configuration problem