Constraining future rows based on past rows

From: Ketema Harris <ketema(at)gmail(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Constraining future rows based on past rows
Date: 2006-04-20 21:16:54
Message-ID: C06D7288.22E3%ketema@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


I have a query in which I want to limit future rows of the result set based
on data in a row that has already been returned. Is this possible?

Example:

company_id | city_id | date_time | weekday | hour_of_day |
company_name | city | max_bookings | currently_booked
------------+---------+---------------------+----------+-------------+------
--------+--------+--------------+------------------
1 | 1 | 2006-04-20 15:30:00 | thursday | 03:30 pm | EFT
| Dallas | 5 | 1
1 | 1 | | monday | 11:00 am | EFT
| Dallas | 4 | 0
1 | 1 | | thursday | 09:00 am | EFT
| Dallas | 3 | 0
1 | 1 | | thursday | 10:00 am | EFT
| Dallas | 6 | 0
1 | 1 | | thursday | 01:00 pm | EFT
| Dallas | 7 | 0
1 | 1 | | thursday | 03:30 pm | EFT
| Dallas | 7 | 0

The above result set is returned from a query. The last row matches the
first, on the day of the week and the time, it just does not have a specific
date. How would I drop that row, but only when the first row is present?
Is this possible?

Extra info is attached.

Thanks,

Ketema

Attachment Content-Type Size
ddl.sql application/octet-stream 8.2 KB

Browse pgsql-novice by date

  From Date Subject
Next Message kadil 2006-04-21 04:59:23 retrieving specified rows
Previous Message Ennio-Sr 2006-04-20 20:40:40 Re: Colors/bold chars in a select?