Microsoft Access分类帐

时间:2018-06-27 07:26:04

标签: sql ms-access

我正在尝试在访问中进行分类。我想要完成的是进行这样的查询。这是我想要的输出:

enter image description here

这是我的查询

SELECT drvYourTable.TransDate, drvYourTable.DrAmount,
    drvYourTable.CrAmount,
    (Select Sum(DrAmount - CrAmount)
        From tblYourtable
        Where tblYourtable.TransDate >= drvYourtable.TransDate
    ) AS Balance
FROM tblYourTable AS drvYourTable
ORDER BY drvYourTable.TransDate;

1 个答案:

答案 0 :(得分:1)

您可能会错过 Nz

declare
v_clob clob;
begin
v_clob := '00102034334:1:11-JUN-13:1,00102034334:2:11-JUN-13:1,00102034334:3:11-JUN-13:1,00102034334:4:11-JUN-13:1,00102034334:5:11-JUN-13:,00102034334:6:11-JUN-13:,00102034334:7:11-JUN-13:,00102034334:8:11-JUN-13:,00102034334:9:11-JUN-13:,00102034334:10:11-JUN-13:,00102034334:11:11-JUN-13:,00102034334:12:11-JUN-13:,00102034334:13:11-JUN-13:,00102034334:14:11-JUN-13:,00102034334:15:11-JUN-13:,00102034334:16:11-JUN-13:,00102034334:17:11-JUN-13:,00102034334:18:11-JUN-13:,00102034334:19:11-JUN-13:,00102034334:20:11-JUN-13:,00102034334:21:11-JUN-13:,00102034334:22:11-JUN-13:,00102034334:23:11-JUN-13:,00102034334:24:11-JUN-13:,00102034334:25:11-JUN-13:,00102034334:26:11-JUN-13:,00102034334:27:11-JUN-13:,00102034334:28:11-JUN-13:,00102034334:29:11-JUN-13:,00102034334:30:11-JUN-13:,00102034334:31:11-JUN-13:,00102034334:32:11-JUN-13:,00102034334:33:11-JUN-13:,00102034334:34:11-JUN-13:,00102034334:35:11-JUN-13:,00102034334:1:11-JUN-13:1,00102034334:2:11-JUN-13:1,00102034334:3:11-JUN-13:1,00102034334:4:11-JUN-13:1,00102034334:5:11-JUN-13:,00102034334:6:11-JUN-13:,00102034334:7:11-JUN-13:,00102034334:8:11-JUN-13:,00102034334:9:11-JUN-13:,00102034334:10:11-JUN-13:,00102034334:11:11-JUN-13:,00102034334:12:11-JUN-13:,00102034334:13:11-JUN-13:,00102034334:14:11-JUN-13:,00102034334:15:11-JUN-13:,00102034334:16:11-JUN-13:,00102034334:17:11-JUN-13:,00102034334:18:11-JUN-13:,00102034334:19:11-JUN-13:,00102034334:20:11-JUN-13:,00102034334:21:11-JUN-13:,00102034334:22:11-JUN-13:,00102034334:23:11-JUN-13:,00102034334:24:11-JUN-13:,00102034334:25:11-JUN-13:,00102034334:26:11-JUN-13:,00102034334:27:11-JUN-13:,00102034334:28:11-JUN-13:,00102034334:29:11-JUN-13:,00102034334:30:11-JUN-13:,00102034334:31:11-JUN-13:,00102034334:32:11-JUN-13:,00102034334:33:11-JUN-13:,00102034334:34:11-JUN-13:,00102034334:35:11-JUN-13:,00102034334:1:11-JUN-13:1,00102034334:2:11-JUN-13:1,00102034334:3:11-JUN-13:1,00102034334:4:11-JUN-13:1,00102034334:5:11-JUN-13:,00102034334:6:11-JUN-13:,00102034334:7:11-JUN-13:,00102034334:8:11-JUN-13:,00102034334:9:11-JUN-13:,00102034334:10:11-JUN-13:,00102034334:11:11-JUN-13:,00102034334:12:11-JUN-13:,00102034334:13:11-JUN-13:,00102034334:14:11-JUN-13:,00102034334:15:11-JUN-13:,00102034334:16:11-JUN-13:,00102034334:17:11-JUN-13:,00102034334:18:11-JUN-13:,00102034334:19:11-JUN-13:,00102034334:20:11-JUN-13:,00102034334:21:11-JUN-13:,00102034334:22:11-JUN-13:,00102034334:23:11-JUN-13:,00102034334:24:11-JUN-13:,00102034334:25:11-JUN-13:,00102034334:26:11-JUN-13:,00102034334:27:11-JUN-13:,00102034334:28:11-JUN-13:,00102034334:29:11-JUN-13:,00102034334:30:11-JUN-13:,00102034334:31:11-JUN-13:,00102034334:32:11-JUN-13:,00102034334:33:11-JUN-13:,00102034334:34:11-JUN-13:,00102034334:35:11-JUN-13:,00102034334:1:11-JUN-13:1,00102034334:2:11-JUN-13:1,00102034334:3:11-JUN-13:1,00102034334:4:11-JUN-13:1,00102034334:5:11-JUN-13:,00102034334:6:11-JUN-13:,00102034334:7:11-JUN-13:,00102034334:8:11-JUN-13:,00102034334:9:11-JUN-13:,00102034334:10:11-JUN-13:,00102034334:11:11-JUN-13:,00102034334:12:11-JUN-13:,00102034334:13:11-JUN-13:,00102034334:14:11-JUN-13:,00102034334:15:11-JUN-13:,00102034334:16:11-JUN-13:,00102034334:17:11-JUN-13:,00102034334:18:11-JUN-13:,00102034334:19:11-JUN-13:,00102034334:20:11-JUN-13:,00102034334:21:11-JUN-13:,00102034334:22:11-JUN-13:,00102034334:23:11-JUN-13:,00102034334:24:11-JUN-13:,00102034334:25:11-JUN-13:,00102034334:26:11-JUN-13:,00102034334:27:11-JUN-13:,00102034334:28:11-JUN-13:,00102034334:29:11-JUN-13:,00102034334:30:11-JUN-13:,00102034334:31:11-JUN-13:,00102034334:32:11-JUN-13:,00102034334:33:11-JUN-13:,00102034334:34:11-JUN-13:,00102034334:35:11-JUN-13:,00102034334:1:11-JUN-13:1,00102034334:2:11-JUN-13:1,00102034334:3:11-JUN-13:1,00102034334:4:11-JUN-13:1,00102034334:5:11-JUN-13:,00102034334:6:11-JUN-13:,00102034334:7:11-JUN-13:,00102034334:8:11-JUN-13:,00102034334:9:11-JUN-13:,00102034334:10:11-JUN-13:,00102034334:11:11-JUN-13:,00102034334:12:11-JUN-13:,00102034334:13:11-JUN-13:,00102034334:14:11-JUN-13:,00102034334:15:11-JUN-13:,00102034334:16:11-JUN-13:,00102034334:17:11-JUN-13:,00102034334:18:11-JUN-13:,00102034334:19:11-JUN-13:,00102034334:20:11-JUN-13:,00102034334:21:11-JUN-13:,00102034334:22:11-JUN-13:,00102034334:23:11-JUN-13:,00102034334:24:11-JUN-13:,00102034334:25:11-JUN-13:,00102034334:26:11-JUN-13:,00102034334:27:11-JUN-13:,00102034334:28:11-JUN-13:,00102034334:29:11-JUN-13:,00102034334:30:11-JUN-13:,00102034334:31:11-JUN-13:,00102034334:32:11-JUN-13:,00102034334:33:11-JUN-13:,00102034334:34:11-JUN-13:,00102034334:35:11-JUN-13:,00102034334:1:11-JUN-13:1,00102034334:2:11-JUN-13:1,00102034334:3:11-JUN-13:1,00102034334:4:11-JUN-13:1,00102034334:5:11-JUN-13:,00102034334:6:11-JUN-13:,00102034334:7:11-JUN-13:,00102034334:8:11-JUN-13:,00102034334:9:11-JUN-13:,00102034334:10:11-JUN-13:,00102034334:11:11-JUN-13:,00102034334:12:11-JUN-13:,00102034334:13:11-JUN-13:,00102034334:14:11-JUN-13:,00102034334:15:11-JUN-13:,00102034334:16:11-JUN-13:,00102034334:17:11-JUN-13:,00102034334:18:11-JUN-13:,00102034334:19:11-JUN-13:,00102034334:20:11-JUN-13:,00102034334:21:11-JUN-13:,00102034334:22:11-JUN-13:,00102034334:23:11-JUN-13:,00102034334:24:11-JUN-13:,00102034334:25:11-JUN-13:,00102034334:26:11-JUN-13:,00102034334:27:11-JUN-13:,00102034334:28:11-JUN-13:,00102034334:29:11-JUN-13:,00102034334:30:11-JUN-13:,00102034334:31:11-JUN-13:,00102034334:32:11-JUN-13:,00102034334:33:11-JUN-13:,00102034334:34:11-JUN-13:,00102034334:35:11-JUN-13:';
select TO_CHAR (regexp_substr(v_clob,'[^,]+', 1, level)) from dual 
               connect by TO_CHAR (regexp_substr(v_clob, '[^,]+', 1, level)) is not null;                       

end;
/