Re: value from max row in group by - Mailing list pgsql-sql

From Gary Stainburn
Subject Re: value from max row in group by
Date
Msg-id 201307260918.51825.gary.stainburn@ringways.co.uk
Whole thread Raw
In response to Re: value from max row in group by  (Marc Mamin <M.Mamin@intershop.de>)
List pgsql-sql
Sorry, but I never thought.

I'm developing this on my server I'm developing it for someone else who wants 
it in a WordPress / MySQL environment (I don't know MySQL).

Would this or something similar work in mysql?

(Sorry for going O.T.)

On Thursday 25 July 2013 19:53:06 Marc Mamin wrote:
> >________________________________________
> >Von: pgsql-sql-owner@postgresql.org [pgsql-sql-owner@postgresql.org]"
> > im Auftrag von "Venky >Kandaswamy [venky@adchemy.com]
> >
> >You can use Postgres WINDOW functions for this in several different ways.
> > For example, one way of doing it:
> >
> >select stts_id,   last_value(stts_offset) over (partition by stts_id order
> > by stts_offset desc) + last_value(stts_duration) over (partition by
> > stts_id order by stts_offset desc) from table
> >group by stts_id;
>
> another simple solution with distinct on:
>
> select distinct on (stts_id, stts_offset) stts_id,
> stts_offset+stts_duration from table
> order by stts_id, stts_offset desc
>
> Marc Mamin
>

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 



pgsql-sql by date:

Previous
From: Marc Mamin
Date:
Subject: Re: value from max row in group by
Next
From: JORGE MALDONADO
Date:
Subject: Unique index and unique constraint