创建条目列表的聚合偏移条目

时间:2014-06-29 12:52:19

标签: sql insert

我有dBase收集构建字符串以上传到ERP系统的财务数据。

示例:

Receipt,   Amount,  Area,  Code, FieldA, GLAccount,     UploadString
   12      50.00    123ABC  0001  1714   123456      50.00 123ABC 0001 1714 123456  
   13      60.00    123ABC  0001  1714   123456      60.00 123ABC 0001 1714 123456
   14      70.00    123ABC  0001  1714   123456      70.00 123ABC 0001 1714 123456

要创建偏移字符串,我使用

Insert into MyTable (Amount,Area,Code,GLAccount)
Select Area
Code
GLAccount ='654321'
sum(Amount*-1)
from MyTable
GroupBy 
Area,Code,GLAccount

导致一行看起来像

[Receipt],[Amount],[Area], [Code], [FieldA],  [GLAccount],        [UploadString]
   Null   -180.00   123ABC  0001    Null         654321      50.00 123ABC 0001 NULL 654321

FieldA中的Null不允许构建上传字符串。

我一直在对派生表进行大量阅读,但我无法正确理解语法。

你们中的任何人都知道如何填充表格中的所有字段,而只使用一些字段来生成偏移量吗?

我想看看:

[Amount],[Area], [Code], [FieldA],  [GLAccount],        [UploadString]
-180.00   123ABC  0001    1714         654321      50.00 123ABC 0001 1714 654321

0 个答案:

没有答案
相关问题