| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: SQL help
Thanks. I hadn't seen the WITH clause before (just how many pages of DB2
UDB documentation are there, any way), but looked it up in the SQL
reference Vol. 1.
Lennart Jonsson wrote:
> Robert Stearns <rstearns1241_at_charter.net> wrote in message news:<10m6rtb9k95it9c_at_corp.supernews.com>...
>
>>This is cross posted because I honestly do not know which of the two >>news groups is more appropriate or more likely to yield a reply. >>
>>The longest owner: MIN(starting) AND starting<=gd AND (ending IS NULL OR >>ending>=gd) >>If there ties, MAX(percent) among them >>If there are still ties, entity_id=geid if it exists >>else longest membership: MIN(entity_id) >>The last is guaranteed to be unique.
>>CREATE TABLE owners >> ( >> bhid BIGINT NOT NULL, >> entity_id INTEGER NOT NULL, >> starting DATE NOT NULL, >> percent DECIMAL(7, 4) NOT NULL DEFAULT 100, >> ending DATE >> ) >> DATA CAPTURE NONE; >> >>ALTER TABLE owners >> ADD CONSTRAINT primary PRIMARY KEY >> (bhid, entity_id, starting);
![]() |
![]() |