数据统计--求助,请高手指点,谢谢!
*-模拟示例表CREATE CURSOR tt (单位 c(50),业务号 C(20),种类 c(20))
INSERT INTO tt VALUES ('中国银行','W202208080105','贷')
INSERT INTO tt VALUES ('中国银行','W202208090005','贷')
INSERT INTO tt VALUES ('中国银行','W202208010005','贷')
INSERT INTO tt VALUES ('中国银行','W202208080104','销')
INSERT INTO tt VALUES ('中国银行','W202208090006','销')
INSERT INTO tt VALUES ('中国银行','W202208020003','冲')
INSERT INTO tt VALUES ('中国银行','W202208050102','冲')
INSERT INTO tt VALUES ('中国银行','W202208060001','冲')
INSERT INTO tt VALUES ('中国银行','W202208030004','冲')
INSERT INTO tt VALUES ('中国银行','W202208011005','冲')
INSERT INTO tt VALUES ('中国银行','W202208016006','冲')
INSERT INTO tt VALUES ('中国银行','W202208019016','冲')
INSERT INTO tt VALUES ('中国银行','W202207030001','冲')
INSERT INTO tt VALUES ('中国银行','W202207011004','销')
INSERT INTO tt VALUES ('中国银行','W202207015006','销')
INSERT INTO tt VALUES ('中国银行','W202207013015','贷')
INSERT INTO tt VALUES ('中国建设银行','W202207080105','贷')
INSERT INTO tt VALUES ('中国建设银行','W202207090005','贷')
INSERT INTO tt VALUES ('中国建设银行','W202207010005','贷')
INSERT INTO tt VALUES ('中国建设银行','W202207080104','销')
INSERT INTO tt VALUES ('中国建设银行','W202207090006','销')
INSERT INTO tt VALUES ('中国建设银行','W202207020003','冲')
INSERT INTO tt VALUES ('中国建设银行','W202207050102','冲')
INSERT INTO tt VALUES ('中国建设银行','W202207060001','冲')
INSERT INTO tt VALUES ('中国建设银行','W202207030004','冲')
INSERT INTO tt VALUES ('中国建设银行','W202207011005','冲')
INSERT INTO tt VALUES ('中国建设银行','W202207016006','冲')
INSERT INTO tt VALUES ('中国建设银行','W202208010004','冲')
INSERT INTO tt VALUES ('中国建设银行','W202208017005','贷')
INSERT INTO tt VALUES ('中国建设银行','W202208014006','销')
SELECT 单位 as 单位,种类;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=1,1,0)) 一月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=2,1,0)) 二月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=3,1,0)) 三月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=4,1,0)) 四月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=5,1,0)) 五月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=6,1,0)) 六月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=7,1,0)) 七月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=8,1,0)) 八月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=9,1,0)) 九月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=10,1,0)) 十月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=11,1,0)) 十一月;
,sum(iif(month(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")))=12,1,0)) 十二月;
from tt grou by 1,2 iNTO curs t1 WHERE BETWEEN(CTOD(TRANSFORM(VAL(LEFT(CHRTRANC(业务号,'W',''),8)),"9999-99-99")),CTOD('2022.01.01'),CTOD('2022.08.31')) READWRITE
FOR lnj=3 TO FCOUNT()
myzd=FIELD(lnj)
BLANK FIELDS (myzd) FOR &myzd=0 &&将所有字段为零的去掉
ENDFOR
*-要下面达到这样的效果,然后还要有小计、合计之类的
CREATE CURSOR tth (单位 c(50),七月 C(20),八月 c(20))
INSERT INTO tth VALUES ('中国建设银行','冲:6/贷:3/销:2','冲:1/贷:1/销:1')
INSERT INTO tth VALUES ('中国银行','冲:1/贷:1/销:2','冲:7/贷:3/销:2')
*-