Search Postgresql Archives

Re: Date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux