SELECT DATEPART(mm,tdjd.oper_date) as 月份,SUM(pos_amt-pos_ret_amt) as 金额 FROM t_da_jxc_daysum tdjd LEFT JOIN t_bd_item_info tbii ON tbii.item_no = tdjd.item_no LEFT JOIN t_bd_item_cls tbic ON tbic.item_clsno = tbii.item_clsno LEFT JOIN t_bd_branch_info tbbi ON LEFT(tbbi.branch_no,4) = tdjd.branch_no WHERE tdjd.oper_date BETWEEN convert(VARCHAR(7), DATEADD(mm,-11,GETDATE()) ,23) AND convert(varchar(10), GETDATE() ,23) ${IF(季节=="","","AND tbii.season_no = '"+季节+"'")} ${IF(品牌=="","","AND LEFT(tbii.item_clsno,2)='"+品牌+"'")} ${IF(大类=="","","AND LEFT(tbii.item_clsno,4)='"+大类+"'")} ${IF(门店=="","","AND tbbi.branch_no = '"+门店+"'")} AND LEFT(tbii.item_clsno,2) IN('01','02','03','04','07','08') GROUP BY CONVERT(varchar(7),tdjd.oper_date,23),datepart(mm,tdjd.oper_date) ORDER BY CONVERT(varchar(7),tdjd.oper_date,23)
时间: 2023-05-14 12:05:26 浏览: 218
时间选择,选择出一个月的日期
这是一个 SQL 查询语句,用于查询某个时间段内不同条件下的销售金额。其中,季节、品牌、大类、门店是可选的筛选条件,如果没有指定,则不会影响查询结果。由于我是一个 AI,我无法直接执行 SQL 查询,但是我可以帮你解读这个查询语句,如果你有相关的数据表和数据,可以尝试在数据库中执行这个查询语句,以获得相应的结果。
阅读全文