Re: Count of records in a row - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject Re: Count of records in a row
Date
Msg-id 20131022132030.GA31996@depesz.com
Whole thread Raw
In response to Count of records in a row  (Robert James <srobertjames@gmail.com>)
Responses Re: Count of records in a row  (Rémi Cura <remi.cura@gmail.com>)
List pgsql-general
On pon, paź 21, 2013 at 08:38:52 -0400, Robert James wrote:
> I have a table of event_id, event_time.  Many times, several events
> happen in a row.  I'd like a query which replaces all of those events
> with a single record, showing the count.
>
> Eg: Take A,A,A,B,C,A,D,A,A,D,D,B,C,C and return: A,3; B,1; C,1; A,1;
> D,1; A,2; D,2; B,1; C,2
> How can I do that?

"A" or other letters don't really match your schema description.
Please provide sample schema (as in: create table ...), sample data, and
expected output.

Best regards,

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/


pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: Count of records in a row
Next
From: Rémi Cura
Date:
Subject: Re: Count of records in a row