grouping subsets - Mailing list pgsql-sql

From Rainer Stengele
Subject grouping subsets
Date
Msg-id i28ubc$ie9$1@dough.gmane.org
Whole thread Raw
Responses Re: grouping subsets
List pgsql-sql
Hi,

having a table similar to

| 1 | B | [2010-07-15 Do] |
| 1 | B | [2010-07-16 Fr] |
|---+---+-----------------|
| 2 | C | [2010-07-17 Sa] |
| 2 | C | [2010-07-18 So] |
|---+---+-----------------|
| 1 | B | [2010-07-19 Mo] |
| 1 | B | [2010-07-20 Di] |
| 1 | B | [2010-07-21 Mi] |
| 1 | B | [2010-07-22 Do] |
|---+---+-----------------|
| 3 | D | [2010-07-23 Fr] |

a simple group by gives me:

| 6 | B |
| 4 | C |
| 3 | D |


What I want to get is the values grouped by "subset", where a subset is a set of rows with identical column until the
columchanges.
 
Is there a way to get

| 2 | B |
| 4 | C |
| 4 | B |
| 3 | D |

by SQL only?

- Rainer






pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Aggregates (last/first) not behaving
Next
From: "A. Kretschmer"
Date:
Subject: Re: grouping subsets