财务短信语句.sql 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --------------------------------------------------------------------------------------------------------
  2. use db
  3. declare
  4. @OrderCount int, --1.当天订单数; --
  5. @ReceiptCount int, --2.当天收款次数; --
  6. @Oreder1 int, --3.当天订单预约收款; --
  7. @Oreder2 int, --4.当天订单补款; --
  8. @Oreder3 int, --5.当天订单后期补款; --
  9. @Oreder4 int, --6.当天订单使用储值卡消费金额; --
  10. @OtherReceipts int, --7.当天其他收入; --
  11. @Payout int, --8.当天支出; --
  12. @OtherSalary int, --9.当天其他二销; --
  13. @MemberReceipts int, --A.当天会员收入; --
  14. @GrossReceipts int, --B.当天总收入; --总收入要扣除储值卡消费的;
  15. @end int --C.结束;
  16. --1.获得当天的订单数目;
  17. select @OrderCount = count(distinct id) from dindanbukuan where 0=datediff(day,date,getdate())
  18. --2.当天收款次数;
  19. select @ReceiptCount = count(id) from dindanbukuan where 0=datediff(day,date,getdate())
  20. --3.当天订单预约收款;
  21. select @Oreder1 = sum(convert(int,money)) from dindanbukuan where 0=datediff(day,date,getdate()) and bz='预约收款'
  22. --4.当天订单补款;
  23. select @Oreder2 = sum(convert(int,money)) from dindanbukuan where 0=datediff(day,date,getdate()) and bz='预约补款'
  24. --5.当天订单后期补款;
  25. select @Oreder3 = sum(convert(int,money)) from dindanbukuan where 0=datediff(day,date,getdate()) and bz not in('预约收款','预约补款')
  26. --6.当天订单使用储值卡消费金额;
  27. select @Oreder4 = sum(convert(int,money)) from dindanbukuan where 0=datediff(day,date,getdate()) and paytype = '储值卡扣款'
  28. --7.当天其他收入;
  29. select @OtherReceipts = sum(convert(float,money)) from singleincome where 0=datediff(day,dat,getdate()) and sale2type is null
  30. --8.当天支出;
  31. select @Payout = sum(convert(float,money)) from gudingfeiyong where 0=datediff(day,dat,getdate())
  32. --9.当天其他二销;
  33. select @OtherSalary = sum(convert(float,money)) from singleincomemoneyview where 0=datediff(day,date,getdate())
  34. --10.当天会员收入;
  35. select @MemberReceipts = sum(convert(float,money)) from memberview where 0=datediff(day,date,getdate())
  36. --11.当天总收入;
  37. select @GrossReceipts = (sum(convert(int,money)) - @Oreder4) from dindanbukuan where 0=datediff(day,date,getdate())