SQL 语句统计

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 

 

你可能感兴趣的:(sql,F#)