我正在使用Sybase 16.我的订单跨越了一段时间,包括开始和结束日期(即7/24 / 16-8 / 6/16 - 14天跨度)。这构成一个记录。我需要从这一行创建多行。上面的例子将变成14条记录。
基本上这个:
000000000020517 000490000002318 7/24/2016 8/1/2016 2 0.071428571 1 1 7/24/2016
000000000020517 000490000002318 7/24/2016 8/1/2016 2 0.071428571 1 1 7/25/2016
000000000020517 000490000002318 7/24/2016 8/1/2016 2 0.071428571 1 1 7/26/2016
000000000020517 000490000002318 7/24/2016 8/1/2016 2 0.071428571 1 1 7/27/2016
000000000020517 000490000002318 7/24/2016 8/1/2016 2 0.071428571 1 1 7/28/2016
000000000020517 000490000002318 7/24/2016 8/1/2016 2 0.071428571 1 1 7/29/2016
000000000020517 000490000002318 7/24/2016 8/1/2016 2 0.071428571 1 1 7/30/2016
000000000020517 000490000002318 7/24/2016 8/1/2016 2 0.071428571 1 1 7/31/2016
000000000020517 000490000002318 7/24/2016 8/1/2016 2 0.071428571 1 1 8/1/2016
会变成这样:
BEGIN
DECLARE LOCAL TEMPORARY TABLE @POSubset (
PatientID CHAR(15),
PatOrdersID CHAR(15),
LowVisits INTEGER,
HighVisits INTEGER,
POStartDate DATE,
POStopDate DATE,
Frequency INTEGER,
VisitsPerDay INTEGER,
OrderString CHAR,
PODate DATE
);
WHILE PO.StartDate <= PO.StopDate LOOP
INSERT INTO @POSubset (PatientID, PatOrdersID, StartDate, StopDate, Frequency, VisitsPerDay, LowVisits, HighVisits, PODate )
SELECT
PO.PatientID,
PO.PatVisitOrdersID,
PO.StartDate,
PO.StopDate,
PO.Frequency,
(PO.LowVisits/PO.Frequency) AS VisitsPerDay,
PO.LowVisits,
PO.HighVisits,
PODate <--- This should be the incrementing value
FROM PatientOrders PO;
SET PODate = PODate+1
END LOOP;
END
我的挖掘让我相信我需要编写一个过程并创建一个临时表来实现这一点。这就是我需要帮助的地方。从我的代码中,你可以说我有点像新手......温柔。
我知道我可能需要设置/声明变量,但这就是我丢失的地方。以下是我正在使用的内容。谢谢。
slather coverage --html --scheme "Myscheme" --output-directory "coverage/reports" --workspace abc.xcworkspace --input-format profdata --build-directory "/Users/xxxx/Library/Developer/Xcode/DerivedData" --source-directory . abc.xcodeproj