SQL 语句统计

本文展示了如何使用SQL查询来获取特定日期区间内的食品头记录、总金额、支付方式等关键信息,并进行分组汇总分析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

select A.foodhead_recordman  as, 
 (select sum(G.groupinfo_je) from groupinfo G  where A.foodhead_id=G.foodhead_id ) as 'tchj',
 (select sum(F.singleinfo_je) from singleinfo F where A.foodhead_id=F.foodhead_id ) as 'dchj',
 sum(A.FOODHEAD_FACT_PRICE) as 'ysje' ,
 sum(A.FOODHEAD_PREFERENTIAL_PRICE) as 'ssje', sum(A.FOODHEAD_PAY_AGIO) as 'zhekouje',
 (select sum(B.PAYWAY_JE) from payways B where A.foodhead_id=B.foodhead_id and  B.payway_name=1) as 'xianjin', 
 (select sum(B.PAYWAY_JE) from payways B where A.foodhead_id=B.foodhead_id and  B.payway_name=2) as 'huiyuanka'
 from foodhead A ,payways B where A.foodhead_id=B.foodhead_id  and convert(A.foodhead_date,date)>='2010-05-24' and convert(A.foodhead_date,date)<='2010-06-01'
 group by  A.foodhead_recordman


select A.foodhead_recordman ,
 sum(A.FOODHEAD_FACT_PRICE) as 'ysje',
 sum(A.FOODHEAD_PREFERENTIAL_PRICE) as 'ssje',
 sum(A.FOODHEAD_PAY_AGIO) as 'zkje',
 (select sum(B.PAYWAY_JE) from payways B where A.foodhead_id=B.foodhead_id and  B.payway_name=1 ) as 'xianjin', 
 (select sum(B.PAYWAY_JE) from payways B where A.foodhead_id=B.foodhead_id and  B.payway_name=2 ) as 'huiyuanka'
 from foodhead A ,payways B where A.foodhead_id=B.foodhead_id and convert(A.foodhead_date,date)>='2010-05-24'
 group by  A.foodhead_recordman


select A.class_id , count(A.foodhead_id) as 'ds', sum(A.FOODHEAD_FACT_PRICE) as 'ysje' ,
  sum(A.FOODHEAD_PREFERENTIAL_PRICE) as 'ssje', sum(A.FOODHEAD_PAY_AGIO) as 'zkje', 
  (select sum(B.PAYWAY_JE) from payways B where A.foodhead_id=B.foodhead_id and  B.payway_name=1 ) as 'xianjin', 
  (select sum(B.PAYWAY_JE) from payways B where A.foodhead_id=B.foodhead_id and  B.payway_name=2 ) as 'huiyuanka' 
  from foodhead A ,payways B where A.foodhead_id=B.foodhead_id and convert(A.foodhead_date,date)>='2010-05-24'
  group by  A.class_id 


select convert(A.foodhead_date,date) as '时间' from foodhead A where convert(A.foodhead_date,date) = '2010-05-24'  

select convert(A.foodhead_date,date) as '时间' from foodhead A 
 where convert(A.foodhead_date,date) >'2010-05-20' and convert(A.foodhead_date,date) <='2010-05-31'


select E.foodhead_recordman, sum(F.singleinfo_je) from foodhead E ,singleinfo F where E.foodhead_id=F.foodhead_id  group by E.foodhead_recordman


select E.foodhead_recordman, sum(G.groupinfo_je) from foodhead E ,groupinfo G  where E.foodhead_id=G.foodhead_id group by E.foodhead_recordman

select sum(B.PAYWAY_JE) from foodhead A ,payways B where A.foodhead_id=B.foodhead_id and convert(A.foodhead_date,date)= '2010-05-24' and  B.payway_name=1


select sum(B.PAYWAY_JE) from foodhead A ,payways B where A.foodhead_id=B.foodhead_id and convert(A.foodhead_date,date)= '2010-05-24' and  B.payway_name=2 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值