码迷,mamicode.com
首页 > 其他好文 > 详细

substring和 DATE_FORMAT截取年,月

时间:2018-12-26 15:49:18      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:png   ima   select   mount   months   com   div   rom   bsp   

SELECT
    x.core_enterprise_id,
    x.years,
    x.months,
    SUM( x.invoice_amount ),
    SUM( x.invoice_tax_amount ),
    SUM( x.total_amount ) ,
x.invoice_date
FROM
    (
    SELECT
        a.core_enterprise_id,
        a.account_receivable,
        b.pay_id,
        b.invoice_amount,
        b.invoice_tax_amount,
        b.total_amount,
        b.invoice_date,
        substring( DATE_FORMAT( b.invoice_date, ‘%Y%m‘ ), 5 ) months,
        DATE_FORMAT( b.invoice_date, ‘%Y‘ ) years 
    FROM
        biz_pay_billing_info b,
        biz_pay_comfirm_info a 
    WHERE
        b.sys_status = 1 
        AND b.pay_id = a.uuid 
        AND a.sys_status = 1 
    ) x 
  WHERE 
   1= 1 
   AND x.months = 01 
   AND x.core_enterprise_id=‘c1003‘
GROUP BY
    x.core_enterprise_id,
    x.months,
    x.years;
    

技术分享图片

 

substring和 DATE_FORMAT截取年,月

标签:png   ima   select   mount   months   com   div   rom   bsp   

原文地址:https://www.cnblogs.com/xiaowoniulx/p/10178964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!