Re: Count of records in a row

From: Rémi Cura <remi(dot)cura(at)gmail(dot)com>
To: depesz(at)depesz(dot)com
Cc: Robert James <srobertjames(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Count of records in a row
Date: 2013-10-22 13:41:33
Message-ID: CAJvUf_tjF3r07fEBE_Ek0fGn2P2VOK5tkg_yqoGfgckeoih=ZQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

héhé,
nice snipping Merlin !

I guess you are almost there, output is still wrong (should be) (
> 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
)

I don't understand enough to make the modifications =)

Cheers,
Rémi-C

2013/10/22 hubert depesz lubaczewski <depesz(at)depesz(dot)com>

> 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/
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shaun Thomas 2013-10-22 13:47:23 Backup Question
Previous Message hubert depesz lubaczewski 2013-10-22 13:20:30 Re: Count of records in a row