From: litu16 <litumelendez@gmail.com>
To: pgsql-admin@postgresql.org
Subject: SELECT column WHERE time_type = 'Break' but only the rows that are after(below) time_type = 'Start'
Date: Sat, 27 Jun 2015 10:43:19 -0700 (MST)
Message-ID: <1435426999355-5855467.post@n5.nabble.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>
))Hi all, currently Im stuck in an issue, hope some good PostgreSQL fellow
programmer could give me a hand with it. This is my table...
<http://postgresql.nabble.com/file/n5855467/screenshot.jpg;
I would like to SELECT all 'time_elapse' WHERE time_type = 'Break' but only
the rows that are after(below) the last(descendent) time_type = 'Start' and
sum them up.
So in the table above I would SELECT...
* time_elapse | time_type | time_index
----------------------------+-------------+-------------
00-00-00 01:00:00.00 | Break | 2.1
00-00-00 01:00:00.00 | Break | 2.2*
So totalbreak = 00-00-00 02:00:00.000
I know how to convert character varying to timestamp in order to sum them
up, But I don't know how would be the syntax to select all possible 'Breaks'
and sum them up (lets say the max Breaks between each 'Start' is nine).
I can hardly imagine a way to do that, so I would like to ask for
suggestions.
Thanks Advanced.
--
View this message in context: http://postgresql.nabble.com/SELECT-column-WHERE-time-type-Break-but-only-the-rows-that-are-after-be...
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
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-admin@postgresql.org
Cc: litumelendez@gmail.com
Subject: Re: SELECT column WHERE time_type = 'Break' but only the rows that are after(below) time_type = 'Start'
In-Reply-To: <1435426999355-5855467.post@n5.nabble.com>
* 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