> A take on a self-join:
>
> SELECT t1.serial, t1.date as dateL, MIN(t2.date) as dateR FROM t t1
> LEFT JOIN t t2 ON t1.serial = t2.serial AND t1.date < t2.date AND
> t2.delivery = 'R'
> WHERE t1.delivery = 'L'
> GROUP BY t1.serial, t1.date
>
> Whether this is any clearer, or runs faster, than
Rodrigo De León skrev:
> On 9/18/07, Philippe Lang <[EMAIL PROTECTED]> wrote:
>> ... into this:
>>
>>
>> serial dateL dateR
>>
>> 1 1 2
>> 1 4
>> 2 1 2
>> 3 1 3
>> 4 2 3
>> 5 3
>
> SELECT t1.serial, t1.DATE AS datel,
On 9/18/07, Philippe Lang <[EMAIL PROTECTED]> wrote:
> ... into this:
>
>
> serial dateL dateR
>
> 1 1 2
> 1 4
> 2 1 2
> 3 1 3
> 4 2 3
> 5 3
SELECT t1.serial, t1.DATE AS datel, t2.DATE AS dater
FROM t t1 LEFT JOIN
[EMAIL PROTECTED] wrote:
> Hi,
>
> I'm trying to find out how to transform this kind of table data
> (history of rental data in a firm):
...
I have answred my own question: yes, there is a pure SQL solution, with
a subselect:
CREATE TABLE foo (
serial integer,
delivery character(
Hi,
I'm trying to find out how to transform this kind of table data (history
of rental data in a firm):
date serial delivery
--
1 1 L
1 2 L
1 3 L
2 1 R
2 2 R
2 4 L
3 5 L
3 3 R
3 4 R
4