INSERT INTO dy_check_statistics (ID, data_date, statistics_type, order_type, province_name, pay_amount, post_amount, promotion_amount, author_coupon_subsidy, actual_zt_pay_promotion, actual_zr_pay_promotion, refund_amount, platform_service_fee, commission, channel_fee, colonel_service_fee, channel_promotion_fee, other_sharing_amount, packing_amount, yfx_amount, promotion_amount_yf, jylp_yp_amount, jylp_wp_amount, txje, create_time, creator_name, update_time, updater_name, deleted, remark) select #{id}, #{date}, '1', NULL, NULL, IFNULL(sum(a.pay_amount),0), IFNULL(sum(a.post_amount),0), IFNULL(sum(a.promotion_amount),0), IFNULL(sum(a.author_coupon_subsidy),0), IFNULL(sum(a.actual_zt_pay_promotion),0), IFNULL(sum(a.actual_zr_pay_promotion),0), IFNULL(sum(a.refund_amount),0), IFNULL(sum(a.platform_service_fee),0), IFNULL(sum(a.commission),0), IFNULL(sum(a.channel_fee),0), IFNULL(sum(a.colonel_service_fee),0), IFNULL(sum(a.channel_promotion_fee),0), IFNULL(sum(a.other_sharing_amount),0), IFNULL(sum(a.packing_amount),0), IFNULL(sum(a.yfx_amount),0), IFNULL(sum(a.promotion_amount_yf),0), IFNULL(sum(a.jylp_yp_amount),0), IFNULL(sum(a.jylp_wp_amount),0), #{txje}, now(), 'system', now(), 'system', 0, NULL from ${fromTable} a
时间: 2024-04-22 07:22:56 浏览: 215
SQL.rar_SQL INSERT_drop_insert into_oracle_sybase
这是一条 SQL 语句,作用是将一个表中的数据插入到另一个表中,并对数据进行汇总计算。具体解释如下:
1. `INSERT INTO dy_check_statistics`:插入数据到 `dy_check_statistics` 表中;
2. `(ID, data_date, statistics_type, order_type, province_name, pay_amount, post_amount, promotion_amount, author_coupon_subsidy, actual_zt_pay_promotion, actual_zr_pay_promotion, refund_amount, platform_service_fee, commission, channel_fee, colonel_service_fee, channel_promotion_fee, other_sharing_amount, packing_amount, yfx_amount, promotion_amount_yf, jylp_yp_amount, jylp_wp_amount, txje, create_time, creator_name, update_time, updater_name, deleted, remark)`:指定插入的列名;
3. `select #{id}, #{date}, '1', NULL, NULL, IFNULL(sum(a.pay_amount),0), IFNULL(sum(a.post_amount),0), IFNULL(sum(a.promotion_amount),0), IFNULL(sum(a.author_coupon_subsidy),0), IFNULL(sum(a.actual_zt_pay_promotion),0), IFNULL(sum(a.actual_zr_pay_promotion),0), IFNULL(sum(a.refund_amount),0), IFNULL(sum(a.platform_service_fee),0), IFNULL(sum(a.commission),0), IFNULL(sum(a.channel_fee),0), IFNULL(sum(a.colonel_service_fee),0), IFNULL(sum(a.channel_promotion_fee),0), IFNULL(sum(a.other_sharing_amount),0), IFNULL(sum(a.packing_amount),0), IFNULL(sum(a.yfx_amount),0), IFNULL(sum(a.promotion_amount_yf),0), IFNULL(sum(a.jylp_yp_amount),0), IFNULL(sum(a.jylp_wp_amount),0), #{txje}, now(), 'system', now(), 'system', 0, NULL`:指定插入的值,其中 `#{id}` 和 `#{date}` 是变量,其余部分是对 `fromTable` 表中各个字段求和;
4. `from ${fromTable} a`:指定数据来源表,其中 `${fromTable}` 是变量,`a` 是该表的别名。
需要注意的是,该 SQL 语句使用了变量,具体的值需要在实际执行时进行替换。
阅读全文