pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedFrom: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: pgsql-sql@postgresql.org
Subject: Re: value from max row in group by
Date: Fri, 26 Jul 2013 09:18:51 +0100
Message-ID: <201307260918.51825.gary.stainburn@ringways.co.uk> (raw)
In-Reply-To: <B6F6FD62F2624C4C9916AC0175D56D880CE11137@jenmbs01.ad.intershop.net>
References: <201307251845.51079.gary.stainburn@ringways.co.uk>
<9d70bbaa0ce84bab8c0467c83fbc01c7@BY2PR05MB237.namprd05.prod.outlook.com>
<B6F6FD62F2624C4C9916AC0175D56D880CE11137@jenmbs01.ad.intershop.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (6+ messages)
Message-ID: <201307260918.51825.gary.stainburn@ringways.co.uk>
Permalink: ../201307260918.51825.gary.stainburn@ringways.co.uk/
Also on: postgresql.org/message-id/201307260918.51825.gary.stainburn@ringways.co.uk
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gary.stainburn@ringways.co.uk
Subject: Re: value from max row in group by
In-Reply-To: <201307260918.51825.gary.stainburn@ringways.co.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox