细心!用心!耐心!

吾非文人,乃市井一俗人也,读百卷书,跨江河千里,故申城一游; 一两滴辛酸,三四年学业,五六点粗墨,七八笔买卖,九十道人情。

BlogJava 联系 聚合 管理
  1 Posts :: 196 Stories :: 10 Comments :: 0 Trackbacks

VALUE:
WITH AA AS(
select a499.MERCHANT_ID,a499.TERMINAL_ID,a499.trans_date,count(*) as count_num,SUM(a499.trans_amount) as count_sum
from DBAT.DTATA499 a499
where a499.MERCHANT_ID IS NOT NULL and a499.INSURANCE_ID = ':INSURANCE_ID' and a499.trans_date=':TRANS_DATE' AND a499.MERCHANT_ID=':MERCHANT_ID'
group by a499.MERCHANT_ID,a499.TERMINAL_ID,a499.trans_date
),
BB AS(
SELECT DISTINCT AA.MERCHANT_ID,b001.POS_TYPE,z020.FELD_NAME,AA.trans_date,AA.TERMINAL_ID,AA.count_num,AA.count_sum
FROM DBAC.DTACB001 b001
join DBAG.DTAGZ020 z020 on  b001.POS_TYPE=z020.FELD_CONT and z020.DBK_NO = 'DJ' And Z020.FELD_NO ='POS_KD'
right JOIN AA  ON AA.MERCHANT_ID=b001.MERCHANT_ID
WHERE  b001.POS_TYPE=':POS_TYPE'
)
select FELD_NAME,TERMINAL_ID,MERCHANT_ID,trans_date,char(bigint(count_num)) count_num,rtrim(char(bigint(count_sum)))||''||translate(rtrim(translate(right(char(count_sum),4)))) count_sum,POS_TYPE from BB with UR

 

其中trans_date,char(bigint(count_num)) 是表示将数据库中BIGDICEMAL数据类型,去除小数点后转换成字符串类型。

posted on 2012-09-11 16:11 张金鹏 阅读(272) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: