querying the value of the previous row - Mailing list pgsql-general

From Chris Velevitch
Subject querying the value of the previous row
Date
Msg-id b0a3bf781003112051s5b2dfa74y686eab907c0fa1d5@mail.gmail.com
Whole thread Raw
Responses Re: querying the value of the previous row  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: querying the value of the previous row  (John R Pierce <pierce@hogranch.com>)
List pgsql-general
I'm to write a query like:-

select
     case when column_name1 <> value_of_previous(column_name1)
          then column_name1 end as column
    ,column_name2

from table
ordered by column_name1, column_name2

in order to get:-

column        | column_name2
--------------+--------------
value_1_c1    |   value_1_c2
              |   value_2_c2
              |   value_3_c2
value_2_c1    |   value_4_c2
              |   value_5_c2

              |   value_6_c2
value_3_c1    |   value_7_c2
              |   value_8_c2
              |   value_9_c2

How do I do this? (I'm using pg 7.4)



Chris
--
Chris Velevitch
Manager - Adobe Platform Users Group, Sydney
m: 0415 469 095
www.apugs.org.au

Adobe Platform Users Group, Sydney
March 2010: ColdFusion Application Architecture for the Impatient and Using jQuery when Flash is Overkill
Date: 29nd Mar 6pm for 6:30 start
Details and RVSP on http://groups.adobe.com/posts/148c9056a4

pgsql-general by date:

Previous
From: jgirvin
Date:
Subject: Re: dst question
Next
From: "Joshua D. Drake"
Date:
Subject: PgEast Hotel discount deadline today!