w*i 发帖数: 63 | 1 A job must done before tomorrow, please help...
we have two tables here,
table 1,
CREATE TABLE dbo.eai_inv_hdr
(
invid numeric(9,0) IDENTITY,
vendorid varchar(10) NOT NULL,
invnbr int NOT NULL,
batchid varchar(10) NOT NULL,
status varchar(1) NOT NULL
)
table2,
CREATE TABLE dbo.eai_inv_dtl
(
invamtid numeric(9,0) IDENTITY,
invid numeric(9,0) NOT NULL,
invamtcd varchar(10) NOT NULL,
invamt decimal(13,2) NOT NULL
)
table example:
| w*i 发帖数: 63 | 2 some explaination, the steps is:
scan all vendorid and invnbr in eai_inv_hdr table,
for those are same of v1 and i1, get their invid,
in this case, 1 and 2. then select all rows in
eai_inv_dtl table which invid are 1 and 2. then
sum the same invamcd, and put the invcmcd and
the sumed number into the destination table.
for those not has a value, put amtcd as NULL
and put amount as 0.
thanks for you guys help...
【在 w*i 的大作中提到】 : A job must done before tomorrow, please help... : we have two tables here, : table 1, : CREATE TABLE dbo.eai_inv_hdr : ( : invid numeric(9,0) IDENTITY, : vendorid varchar(10) NOT NULL, : invnbr int NOT NULL, : batchid varchar(10) NOT NULL, : status varchar(1) NOT NULL
|
|