USE [RGDB] GO /****** Object: StoredProcedure [dbo].[Proc_GetYYQK4] Script Date: 01/10/2026 10:24:06 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE PROCEDURE [dbo].[Proc_GetYYQK4] -- Add the parameters for the stored procedure here @sid nvarchar(10), @report_date date AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; declare @BDate date, @EDate date; set @BDate=DATEADD(DAY,-DAY(@report_date)+1,@report_date); set @EDate=@report_date -- Insert statements for procedure here select drczkzb,drhykzb,drczkje,dyczkje,ISNULL(drhyksl,0)drhyksl,ISNULL(dyhyksl,0)dyhyksl from( select JYYS_CZKXSFJ drczkzb,JYYS_HYKXSFJ drhykzb, (select ISNULL(SUM(jye),0) drczje from YZ_Details where jydd_sid=@sid and jylx='储值充值' and CONVERT(date, jysj, 23)=@report_date and klx in (select hyklx_name from Base_hyklx) and used=1)drczkje, (select ISNULL(SUM(jye),0) dyczje from YZ_Details where jydd_sid=@sid and jylx='储值充值' and CONVERT(date, jysj, 23) between @BDate and @EDate and klx in (select hyklx_name from Base_hyklx) and used=1)dyczkje, (Select SUM(quantity)drhyksl from SC_RA_Details a left join SC_RA_Orders b on a.sid=b.sid and a.order_id=b.id where b.sid=@sid and b.report_date=@report_date and a.menu_name LIKE '会员卡%')drhyksl, (Select SUM(quantity)drhyksl from SC_RA_Details a left join SC_RA_Orders b on a.sid=b.sid and a.order_id=b.id where b.sid=@sid and b.report_date between @BDate and @EDate and menu_name LIKE '会员卡%')dyhyksl from REP_JYYS where JYYS_StoreID=@sid and JYYS_Date=@report_date) a END GO