-1

我在 c# 中有一个查询。我可以在 datagridview 中看到数据。这是我的代码

select welding_date
, (select SUM(mat_2_size) 
from fabrication_table fab_2 
where fab_1.welding_date = fab_2.welding_date 
and (fab_2.welder_1 like '%" + welder + "%' or fab_2.welder_2 like '%" + welder + "%'))as 'TOTAL 
SUM'
,(select SUM(mat_2_size) 
from fabrication_table fab_2 
where mat_2='AS' and fab_1.welding_date = fab_2.welding_date 
and (fab_2.welder_1 like '%" + welder + "%' or fab_2.welder_2 like '%" + welder + "%')) 
as 'SUM OF AS'
,(select SUM(mat_2_size) 
from fabrication_table fab_2 
where mat_2='SS' and fab_1.welding_date = fab_2.welding_date  
and (fab_2.welder_1 like '%" + welder + "%' or fab_2.welder_2 like '%" + welder + "%'))as 'SUM OF SS'
,(select SUM(mat_2_size) 
from fabrication_table fab_2 
where mat_2='CS' and fab_1.welding_date = fab_2.welding_date 
and (fab_2.welder_1 like '%" + welder + "%' or fab_2.welder_2 like '%" + welder + "%')) as 'SUM OF CS' 
from fabrication_table fab_1 
where welding_date between @date1 and @date2 
group by welding_date order by welding_date

这是我在 datagridview 上的结果

http://enderaric.com/calisma/q.PNG

现在我想在 Crystal Report 上看到这张表。这是紧急声明!

我的问题摘要我有一个表格,包括 mat_2_size ,mat_2 ,welding_date ,welder_1,welder_2 ,我想合计 mat_2_size @date1 和 @date2 之间的范围,总大小 mat_2=CS 或 AS 或 SS。我想显示这样的每一行 Date ,总和,mat_2 ='CS'的总和,mat_2 ='AS'的总和,mat_2 ='SS'的总和

4

1 回答 1

0

试试这个作为你的 where 语句:

where datediff(day,@date1,weldingdate) >= 0
  and datediff(day,weldingdate,@date2) >= 0
于 2013-09-17T17:35:48.263 回答