Re: Need some help with a query (uniq -c)

From: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>
To: A B <gentosaker(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Need some help with a query (uniq -c)
Date: 2010-04-12 18:45:55
Message-ID: g2sc3a7de1f1004121145q58dccbaeo2c189e028520ac32@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12 April 2010 22:22, A B <gentosaker(at)gmail(dot)com> wrote:
>
> first |  message | last | count
> --------------------------------------
> 1     |     a              |   1   |     1
> 2     |     b              |   4   |     3     <--- here it squeezes
> similar consecutive messages into a single row
> 5     |     a              |   5   |     1
>
> How do I write such a command?

select min(time) as first, max(time) as last, message, count(*) from
log_table group by message order by 1;

--
Sergey Konoplev

Blog: http://gray-hemp.blogspot.com /
Linkedin: http://ru.linkedin.com/in/grayhemp /
JID/GTalk: gray(dot)ru(at)gmail(dot)com / Skype: gray-hemp / ICQ: 29353802

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2010-04-12 19:17:30 Re: Need some help with a query (uniq -c)
Previous Message Scott Marlowe 2010-04-12 18:31:05 Re: Need some help with a query (uniq -c)