Skip to content

=$
|

  • Why upgrade PG?
  • explain.D.C
  • paste.D.C
  • Waiting for …
    • … PostgreSQL 16
    • … PostgreSQL 15
    • … PostgreSQL 14
    • … PostgreSQL 13
    • … PostgreSQL 12
    • … PostgreSQL 11
    • … PostgreSQL 10
    • … PostgreSQL 9.6
    • … PostgreSQL 9.5
    • … PostgreSQL 9.4
    • … PostgreSQL 9.3
    • … PostgreSQL 9.2
    • … PostgreSQL 9.1
    • … PostgreSQL 9.0
    • … PostgreSQL 8.5
    • … PostgreSQL 8.4
  • Projects
  • Contact

Tag: rank

Tips n’ tricks – rank on changes

I got asked this: having this table:

# select * from a order by d;
 t | d  
---+----
 O |  1
 O |  2
 O |  3
 M |  4
 M |  5
 M |  6
 M |  7
 O |  8
 O |  9
 O | 10
 I | 11
 I | 12
 I | 13
(13 rows)

Is it possible to add “rank" column, that will increment whenever t changed?

Continue reading Tips n' tricks – rank on changes

Posted on 2010-05-13|Tags changes, count, lag, nullif, postgresql, rank, tnt, window functions|3 Comments on Tips n’ tricks – rank on changes

Search

Follow me

  • Comments RSS
  • Posts RSS

Popular Posts

  • System roles – what, why, how? 858 views | 2 comments
  • Explaining the unexplainable – part 3 209 views | 0 comments
  • CHAR(x) vs. VARCHAR(x) vs. VARCHAR vs. TEXT – UPDATED 2010-03-03 196 views | 0 comments
  • Explaining the unexplainable – part 2 181 views | 0 comments
  • “ERROR: operator does not exist: integer = text” how to fix it? 149 views | 0 comments
  • Waiting for PostgreSQL 11 – Fast ALTER TABLE ADD COLUMN with a non-NULL default 135 views | 0 comments
  • how to insert data to database – as fast as possible 123 views | 0 comments
  • Understanding pg_stat_activity 108 views | 0 comments
  • How much RAM is PostgreSQL using? 90 views | 0 comments
  • Explaining the unexplainable 86 views | 0 comments

PostgreSQL

  • Documentation
  • Explain Analyze analyzer
  • IRC help channel
  • Mailing Lists search
  • PG Planet
  • PostgreSQL Home Page

About me

  • CPAN
  • GitLab
  • Linked In
  • Why upgrade PG?
  • explain.D.C
  • paste.D.C
  • Waiting for …
    • … PostgreSQL 16
    • … PostgreSQL 15
    • … PostgreSQL 14
    • … PostgreSQL 13
    • … PostgreSQL 12
    • … PostgreSQL 11
    • … PostgreSQL 10
    • … PostgreSQL 9.6
    • … PostgreSQL 9.5
    • … PostgreSQL 9.4
    • … PostgreSQL 9.3
    • … PostgreSQL 9.2
    • … PostgreSQL 9.1
    • … PostgreSQL 9.0
    • … PostgreSQL 8.5
    • … PostgreSQL 8.4
  • Projects
  • Contact