Re: Date

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Date
Date: 2006-12-29 07:24:06
Message-ID: 20061229072406.GA13834@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

  • Date at 2006-12-28 15:24:30 from ice

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2006-12-29 07:27:56 Re: LDAP configuration problem
Previous Message Ben 2006-12-29 07:11:47 Re: Geographical redundancy