Here's a requirement I had to recently solve using SQL. I managed to come up with a solution, but it's a bit elaborate and cumbersome.
Without sharing my solution just now, I was wondering how you would solve this.
Given a table:
(orderlineid number not null
,arrival_starttime date not null
,arrival_stoptime date not null
,article_id varchar2(10) not null
,quantity number(4,0) not null
check(quantity > 0)
,check(trunc(arrival_starttime) = trunc(arrival_stoptime))
,check(arrival_starttime < arrival_stoptime)
,primary key (orderlineid)
Let's say we have following four tuples:
Per orderline we need to distribute the quantity over the 5-minute slots for that orderline:
For a given date, then the final resultset should look like this: