Complex query

From: Leonardo M(dot) Ramé <l(dot)rame(at)griensu(dot)com>
To: PostgreSql-general <pgsql-general(at)postgresql(dot)org>
Subject: Complex query
Date: 2014-03-31 18:38:15
Message-ID: 20140331183815.GA10833@leonardo-laptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, I'm looking for help with this query.

Table Tasks:

IdTask StatusCode StatusName
----------------------------------
1 R Registered
1 S Started
1 D Dictated
1 F Finished
1 T Transcribed
----------------------------------
2 R Registered
2 S Started
2 T Transcribed
2 F Finished

As you can see, I have a table containing tasks and statuses. What I
would like to get is the list of tasks, including all of its steps, for
only those tasks where the StatusCode sequence was S followed by T.

In this example, the query should only return task Nº 2:

2 R Registered
2 S Started
2 T Transcribed
2 F Finished

Can anybody help me with this?.

Regards,
--
Leonardo M. Ramé
Medical IT - Griensu S.A.
Av. Colón 636 - Piso 8 Of. A
X5000EPT -- Córdoba
Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19
Cel.: +54 9 (011) 40871877

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2014-03-31 18:46:28 Re: Complex query
Previous Message Alvaro Herrera 2014-03-31 18:07:34 Re: char array overhead