REPORTFORM;TESTCROSS1.frf
TITLE;
SQL;drop table if exists _head&
SQL;create table _head
SQL;select  
SQL;apcard.DPTID, space(10) as Head
SQL;from apcard 
SQL;inner join depart on apcard.DPTID = depart.DID
SQL;group by 1
SQL;limit 5&
SQL;ALTER TABLE `_head`
SQL;	ADD COLUMN `line` INT NOT NULL AUTO_INCREMENT AFTER `Head`,
SQL;	ADD PRIMARY KEY (`line`)&
SQL;update _head set _head.Head = concat('S',line)&
SQL;
SQL;drop table if exists _datacross1&
SQL;create table _datacross1
SQL;select apcard.ACCID, apmst.XCOMP, 
SQL;if(_head.Head = 'S1',apcard.AMOUNT_d,0) as s1,
SQL;if(_head.Head = 'S2',apcard.AMOUNT_d,0) as s2,
SQL;if(_head.Head = 'S3',apcard.AMOUNT_d,0) as s3,
SQL;if(_head.Head = 'S4',apcard.AMOUNT_d,0) as s4,
SQL;if(_head.Head = 'S5',apcard.AMOUNT_d,0) as s5
SQL;from apcard inner join apmst on apcard.ACCID = apmst.ACCID
SQL;inner join _head on apcard.DPTID = _head.DPTID&
SQL;
SQL;drop table if exists _datacross2&
SQL;create table _datacross2 
SQL;select accid,xcomp,
SQL;sum(s1) as s1,
SQL;sum(s2) as s2,
SQL;sum(s3) as s3,
SQL;sum(s4) as s4,
SQL;sum(s5) as s5
SQL;from _datacross1
SQL;group by 1,2&
SQL;
SQL;select * from _datacross2
CONDITION;΅Ρι§α΅θΗΡΉ·Υθ~APCARD.DATEDOC~Date~2~~
