×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
From: Steve Richter
-- this view selects all of the owner's events
create view OwnerItemEvents as
(
select a.OwnerName, a.itemId,
b.eventText, b.eventTs
from ItemOwner a
join ItemEvents b
on a.itemId = b.itemId
order by a.OwnerName, a.itemId, b.eventTs
) ;
Nope, this is wrong. INVENTORY and OWNER don't have a 1-to-1 relationship.
OWNER->INVENTORY is 1-to-N, with the only relationship being relative time:
OWNER 1 "Joe" at 12:01
INVENTORY 1 "Event 1" at 12:02
INVENTORY 1 "Event 2" at 12:03
INVENTORY 1 "Event 3" at 12:04
OWNER 1 "Frank" at 12:10
INVENTORY 1 "Event 4" at 12:11
INVENTORY 1 "Event 5" at 12:12
The only thing that makes Events 1-3 belong to Joe is the fact that the
OWNER record for Joe occurred before those events. Events 4 and 5 belong to
Frank because the Frank OWNER record occurred before Event 4.
This is why I noted in my previous post that this problem is perfect for
matching records. The primary key is control number (in this case, 1),
while the secondary key is time. You could write this entire report without
a single C-spec.
The funny thing is that, if you don't understand matching record logic,
trying to figure out the SQL is tough. Note that it's the old native I/O
RPG dinosaur who figured out the right SQL code <grin>.
Joe
As an Amazon Associate we earn from qualifying purchases.