[prog] Sql query

Cynthia Kiser cnk at ugcs.caltech.edu
Thu Jul 14 07:51:58 EST 2005


How much other code exists that accesses older rows from this table?
If I could, I would change this single table with all the data into a
pair - one table of the current data, and one table of the older
date. In fact, most of my database designs have foo and
foo_audit. Then all the current data is in foo and can be accessed
immediately. When I need current older data, then I have to do a join
on the two tables to get all current and past data for something. 

Quoting Tiera <tiera at bredband.net>:
> Yes, I know... but I can't come up with anything else that works at the
> moment. The problem with you query above is that the only status I'm
> interested in is the status for the last period for every product. So if I
> have a product that has two periods, the first one with status 'Special'
> and the last one with status 'Ordinary' and I use your query to pick out
> all products with status 'Special' I would get this product, but that's
> not correct since this product now has status 'Ordinary'.
> The problem would be much easier to solve if there always was one period
> with no enddate...but unfortunately that's not the case. Or another column
> that would tell if it was the last period or not...should have thought of
> that earlier perhaps...

-- 
Cynthia N. Kiser



More information about the Programming mailing list