C# 使用多个筛选器填充winform图表

C# 使用多个筛选器填充winform图表,c#,sql-server,visual-studio,winforms,charts,C#,Sql Server,Visual Studio,Winforms,Charts,在我的winform应用程序中,如果数据源是具有多个参数的存储过程,我希望填充图表,参数值将从winform控件提供。 但是,当我单击“筛选”按钮时,只有日期标准得到评估,而所有其他标准没有得到评估,请验证我下面的图像和代码,并指导我哪里有错: 我的winform的图像: 图表数据代码: ArrayList deptname = new ArrayList(); ArrayList deptcount = new ArrayList(); ArrayList deptna

在我的winform应用程序中,如果数据源是具有多个参数的存储过程,我希望填充图表,参数值将从winform控件提供。 但是,当我单击“筛选”按钮时,只有日期标准得到评估,而所有其他标准没有得到评估,请验证我下面的图像和代码,并指导我哪里有错:

我的winform的图像:

图表数据代码:

ArrayList deptname = new ArrayList();
     ArrayList deptcount = new ArrayList();

     ArrayList deptname2 = new ArrayList();
     ArrayList deptsum2 = new ArrayList();

     ArrayList rejcat = new ArrayList();
     ArrayList rejsum = new ArrayList();

     private void btnfilter_Click(object sender, EventArgs e)
     {
         deptname.Clear();
         deptcount.Clear();
         deptpercentage();
         deptname2.Clear();
         deptsum2.Clear();
         deptrejqty();
         rejcat.Clear();
         rejsum.Clear();
         toprejreason();
     }

     private void toprejreason()
     {
         SqlConnection con = new SqlConnection(cs);
         SqlCommand cmd = new SqlCommand("toprejreason", con);
         cmd.Parameters.AddWithValue("@fromDate", dtfrom.Value);
         cmd.Parameters.AddWithValue("@toDate", dtto.Value);
         cmd.Parameters.AddWithValue("@depname", comboBox1.Text);
         cmd.Parameters.AddWithValue("@mattype", textBox1.Text);
         cmd.Parameters.AddWithValue("@matnum", textBox2.Text);
         cmd.CommandType = CommandType.StoredProcedure;
         con.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             rejcat.Add(dr.GetString(0));
             rejsum.Add(dr.GetInt32(1));
         }
         chart1.Series[0].Points.DataBindXY(rejcat, rejsum);
         dr.Close();
         con.Close();
     }

     private void deptrejqty()
     {
         SqlConnection con = new SqlConnection(cs);
         SqlCommand cmd = new SqlCommand("deptrejqty", con);
         cmd.Parameters.AddWithValue("@fromDate", dtfrom.Value);
         cmd.Parameters.AddWithValue("@toDate", dtto.Value);
         cmd.Parameters.AddWithValue("@depname", comboBox1.Text);
         cmd.Parameters.AddWithValue("@mattype", textBox1.Text);
         cmd.Parameters.AddWithValue("@matnum", textBox2.Text);
         cmd.CommandType = CommandType.StoredProcedure;
         con.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             deptname2.Add(dr.GetString(0));
             deptsum2.Add(dr.GetDecimal(1));
         }
         deptrej.Series[0].Points.DataBindXY(deptname2, deptsum2);
         dr.Close();
         con.Close();
     }


     private void deptpercentage()
     {
         SqlConnection con = new SqlConnection(cs);
         SqlCommand cmd = new SqlCommand("deptpercentage", con);
         cmd.Parameters.AddWithValue("@fromDate", dtfrom.Value);
         cmd.Parameters.AddWithValue("@toDate", dtto.Value);
         cmd.Parameters.AddWithValue("@depname", comboBox1.Text);
         cmd.Parameters.AddWithValue("@mattype", textBox1.Text);
         cmd.Parameters.AddWithValue("@matnum", textBox2.Text);
         cmd.CommandType = CommandType.StoredProcedure;
         con.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             deptname.Add(dr.GetString(0));
             deptcount.Add(dr.GetDecimal(1));
         }
         chartdeptper.Series[0].Points.DataBindXY(deptname, deptcount);
         dr.Close();
         con.Close();
     }

     private void FormDashboard_FormClosed(object sender, FormClosedEventArgs e)
     {
         Application.Exit();
     }
 }
}

存储过程的代码:

    create proc toprejreason
 @fromDate Date,
 @toDate Date,
 @depname varchar,
 @mattype varchar,
 @matnum varchar
 as
 select top 10 Reason_Brief as Reason, Sum(Rejection_Qty) as Quantity
 from Semicon_NPD
 Where Date between  @fromDate  and  @toDate or Department=@depname or Material_Type=@mattype or Material_Number=@matnum
 group by Reason_Brief
 order by Sum(Rejection_Qty) desc
 go
@fromDate Date,
@toDate Date,
@depname varchar(50),
@mattype varchar(50),
@matnum varchar(50)
as
select top 10 Reason_Brief as Reason, Sum(Rejection_Qty) as Quantity
from Semicon_NPD
Where Date between  @fromDate  and  @toDate or Department=@depname or Material_Type=@mattype or Material_Number=@matnum
group by Reason_Brief
order by Sum(Rejection_Qty) desc



    <body>
<!--[if !excel]>&nbsp;&nbsp;<![endif]-->
<!--The following information was generated by Microsoft Excel's Publish as Web
Page wizard.-->
<!--If the same item is republished from Excel, all information between the DIV
tags will be replaced.-->
<!----------------------------->
<!--START OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD -->
<!----------------------------->

<div id="Book1_2966" align="center" x:publishsource="Excel">

<table border="0" cellpadding="0" cellspacing="0" width="2209" style="border-collapse:
 collapse;table-layout:fixed;width:1662pt">
 <colgroup><col width="20" style="mso-width-source:userset;mso-width-alt:731;width:15pt">
 <col width="73" style="mso-width-source:userset;mso-width-alt:2669;width:55pt">
 <col width="35" style="mso-width-source:userset;mso-width-alt:1280;width:26pt">
 <col width="118" style="mso-width-source:userset;mso-width-alt:4315;width:89pt">
 <col width="97" style="mso-width-source:userset;mso-width-alt:3547;width:73pt">
 <col width="94" style="mso-width-source:userset;mso-width-alt:3437;width:71pt">
 <col width="102" style="mso-width-source:userset;mso-width-alt:3730;width:77pt">
 <col width="72" style="mso-width-source:userset;mso-width-alt:2633;width:54pt">
 <col width="96" style="mso-width-source:userset;mso-width-alt:3510;width:72pt">
 <col width="82" style="mso-width-source:userset;mso-width-alt:2998;width:62pt">
 <col width="117" style="mso-width-source:userset;mso-width-alt:4278;width:88pt">
 <col width="342" style="mso-width-source:userset;mso-width-alt:12507;width:257pt">
 <col width="110" span="4" style="mso-width-source:userset;mso-width-alt:4022;
 width:83pt">
 <col width="336" style="mso-width-source:userset;mso-width-alt:12288;width:252pt">
 <col width="92" style="mso-width-source:userset;mso-width-alt:3364;width:69pt">
 <col width="93" style="mso-width-source:userset;mso-width-alt:3401;width:70pt">
 </colgroup><tbody><tr height="20" style="height:15.0pt">
  <td height="20" class="xl652966" width="20" style="height:15.0pt;width:15pt">ID</td>
  <td class="xl652966" width="73" style="border-left:none;width:55pt">Date</td>
  <td class="xl652966" width="35" style="border-left:none;width:26pt">MRP</td>
  <td class="xl652966" width="118" style="border-left:none;width:89pt">Material_Number</td>
  <td class="xl652966" width="97" style="border-left:none;width:73pt">Material_Type</td>
  <td class="xl652966" width="94" style="border-left:none;width:71pt">Weight_in_Kg</td>
  <td class="xl652966" width="102" style="border-left:none;width:77pt">Order_Number</td>
  <td class="xl652966" width="72" style="border-left:none;width:54pt">Order_Qty</td>
  <td class="xl652966" width="96" style="border-left:none;width:72pt">Rejection_Qty</td>
  <td class="xl652966" width="82" style="border-left:none;width:62pt">Department</td>
  <td class="xl652966" width="117" style="border-left:none;width:88pt">Reason_Brief</td>
  <td class="xl652966" width="342" style="border-left:none;width:257pt">Reason_Explained</td>
  <td class="xl652966" width="110" style="border-left:none;width:83pt">Responsibility_1</td>
  <td class="xl652966" width="110" style="border-left:none;width:83pt">Responsibility_2</td>
  <td class="xl652966" width="110" style="border-left:none;width:83pt">Responsibility_3</td>
  <td class="xl652966" width="110" style="border-left:none;width:83pt">Responsibility_4</td>
  <td class="xl652966" width="336" style="border-left:none;width:252pt">Corrective_Action</td>
  <td class="xl652966" width="92" style="border-left:none;width:69pt">Action_Taken</td>
  <td class="xl652966" width="93" style="border-left:none;width:70pt">Action_Status</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">1</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">13-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">A</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.233</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">336</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">2</td>
  <td class="xl632966" style="border-top:none;border-left:none">Milling</td>
  <td class="xl632966" style="border-top:none;border-left:none">Surface Defect</td>
  <td class="xl632966" style="border-top:none;border-left:none">Ahite paches
  appear on surface</td>
  <td class="xl632966" style="border-top:none;border-left:none">Grinding</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Common Problem,
  Analysis to be requeired</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Pending</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">2</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">13-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">A</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.272</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">30</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" style="border-top:none;border-left:none">Milling</td>
  <td class="xl632966" style="border-top:none;border-left:none">Surface Defect</td>
  <td class="xl632966" style="border-top:none;border-left:none">Unclear appear on
  3.1mm slot after milling operation</td>
  <td class="xl632966" style="border-top:none;border-left:none">NPD</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Common Problem,
  Analysis to be done</td>
  <td class="xl632966" style="border-top:none;border-left:none">&nbsp;</td>
  <td class="xl632966" style="border-top:none;border-left:none">Pending</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">3</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">14-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">101</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">A</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.093</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">3</td>
  <td class="xl632966" style="border-top:none;border-left:none">Turning</td>
  <td class="xl632966" style="border-top:none;border-left:none">Chipping</td>
  <td class="xl632966" style="border-top:none;border-left:none">small chippoff on
  edge</td>
  <td class="xl632966" style="border-top:none;border-left:none">Process</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">From Next Bacth
  order Aill take care of this problem</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Pending</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">4</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">15-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">AL10</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.079</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" style="border-top:none;border-left:none">EDM</td>
  <td class="xl632966" style="border-top:none;border-left:none">Out of Dimension</td>
  <td class="xl632966" style="border-top:none;border-left:none">Side slot -0.02
  minimum side comes in milling</td>
  <td class="xl632966" style="border-top:none;border-left:none">Operators</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">No</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Not required</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">5</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">15-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">101</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">TZM</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.083</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">63</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" style="border-top:none;border-left:none">EDM</td>
  <td class="xl632966" style="border-top:none;border-left:none">Chipping</td>
  <td class="xl632966" style="border-top:none;border-left:none">small chippoff on
  edge</td>
  <td class="xl632966" style="border-top:none;border-left:none">Grinding</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Setters should be
  take care of this problem</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Completed</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">9</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">15-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">A</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.083</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">63</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" style="border-top:none;border-left:none">Milling</td>
  <td class="xl632966" style="border-top:none;border-left:none">Chipping</td>
  <td class="xl632966" style="border-top:none;border-left:none">small chipoff</td>
  <td class="xl632966" style="border-top:none;border-left:none">Grinding</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">No</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Not required</td>
 </tr>
 <!--[if supportMisalignedColumns]-->
 <tr height="0" style="display:none">
  <td width="20" style="width:15pt"></td>
  <td width="73" style="width:55pt"></td>
  <td width="35" style="width:26pt"></td>
  <td width="118" style="width:89pt"></td>
  <td width="97" style="width:73pt"></td>
  <td width="94" style="width:71pt"></td>
  <td width="102" style="width:77pt"></td>
  <td width="72" style="width:54pt"></td>
  <td width="96" style="width:72pt"></td>
  <td width="82" style="width:62pt"></td>
  <td width="117" style="width:88pt"></td>
  <td width="342" style="width:257pt"></td>
  <td width="110" style="width:83pt"></td>
  <td width="110" style="width:83pt"></td>
  <td width="110" style="width:83pt"></td>
  <td width="110" style="width:83pt"></td>
  <td width="336" style="width:252pt"></td>
  <td width="92" style="width:69pt"></td>
  <td width="93" style="width:70pt"></td>
 </tr>
 <!--[endif]-->
</tbody></table>

</div>


<!----------------------------->
<!--END OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD-->
<!----------------------------->



</body>
新程序:

    create proc toprejreason
 @fromDate Date,
 @toDate Date,
 @depname varchar,
 @mattype varchar,
 @matnum varchar
 as
 select top 10 Reason_Brief as Reason, Sum(Rejection_Qty) as Quantity
 from Semicon_NPD
 Where Date between  @fromDate  and  @toDate or Department=@depname or Material_Type=@mattype or Material_Number=@matnum
 group by Reason_Brief
 order by Sum(Rejection_Qty) desc
 go
@fromDate Date,
@toDate Date,
@depname varchar(50),
@mattype varchar(50),
@matnum varchar(50)
as
select top 10 Reason_Brief as Reason, Sum(Rejection_Qty) as Quantity
from Semicon_NPD
Where Date between  @fromDate  and  @toDate or Department=@depname or Material_Type=@mattype or Material_Number=@matnum
group by Reason_Brief
order by Sum(Rejection_Qty) desc



    <body>
<!--[if !excel]>&nbsp;&nbsp;<![endif]-->
<!--The following information was generated by Microsoft Excel's Publish as Web
Page wizard.-->
<!--If the same item is republished from Excel, all information between the DIV
tags will be replaced.-->
<!----------------------------->
<!--START OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD -->
<!----------------------------->

<div id="Book1_2966" align="center" x:publishsource="Excel">

<table border="0" cellpadding="0" cellspacing="0" width="2209" style="border-collapse:
 collapse;table-layout:fixed;width:1662pt">
 <colgroup><col width="20" style="mso-width-source:userset;mso-width-alt:731;width:15pt">
 <col width="73" style="mso-width-source:userset;mso-width-alt:2669;width:55pt">
 <col width="35" style="mso-width-source:userset;mso-width-alt:1280;width:26pt">
 <col width="118" style="mso-width-source:userset;mso-width-alt:4315;width:89pt">
 <col width="97" style="mso-width-source:userset;mso-width-alt:3547;width:73pt">
 <col width="94" style="mso-width-source:userset;mso-width-alt:3437;width:71pt">
 <col width="102" style="mso-width-source:userset;mso-width-alt:3730;width:77pt">
 <col width="72" style="mso-width-source:userset;mso-width-alt:2633;width:54pt">
 <col width="96" style="mso-width-source:userset;mso-width-alt:3510;width:72pt">
 <col width="82" style="mso-width-source:userset;mso-width-alt:2998;width:62pt">
 <col width="117" style="mso-width-source:userset;mso-width-alt:4278;width:88pt">
 <col width="342" style="mso-width-source:userset;mso-width-alt:12507;width:257pt">
 <col width="110" span="4" style="mso-width-source:userset;mso-width-alt:4022;
 width:83pt">
 <col width="336" style="mso-width-source:userset;mso-width-alt:12288;width:252pt">
 <col width="92" style="mso-width-source:userset;mso-width-alt:3364;width:69pt">
 <col width="93" style="mso-width-source:userset;mso-width-alt:3401;width:70pt">
 </colgroup><tbody><tr height="20" style="height:15.0pt">
  <td height="20" class="xl652966" width="20" style="height:15.0pt;width:15pt">ID</td>
  <td class="xl652966" width="73" style="border-left:none;width:55pt">Date</td>
  <td class="xl652966" width="35" style="border-left:none;width:26pt">MRP</td>
  <td class="xl652966" width="118" style="border-left:none;width:89pt">Material_Number</td>
  <td class="xl652966" width="97" style="border-left:none;width:73pt">Material_Type</td>
  <td class="xl652966" width="94" style="border-left:none;width:71pt">Weight_in_Kg</td>
  <td class="xl652966" width="102" style="border-left:none;width:77pt">Order_Number</td>
  <td class="xl652966" width="72" style="border-left:none;width:54pt">Order_Qty</td>
  <td class="xl652966" width="96" style="border-left:none;width:72pt">Rejection_Qty</td>
  <td class="xl652966" width="82" style="border-left:none;width:62pt">Department</td>
  <td class="xl652966" width="117" style="border-left:none;width:88pt">Reason_Brief</td>
  <td class="xl652966" width="342" style="border-left:none;width:257pt">Reason_Explained</td>
  <td class="xl652966" width="110" style="border-left:none;width:83pt">Responsibility_1</td>
  <td class="xl652966" width="110" style="border-left:none;width:83pt">Responsibility_2</td>
  <td class="xl652966" width="110" style="border-left:none;width:83pt">Responsibility_3</td>
  <td class="xl652966" width="110" style="border-left:none;width:83pt">Responsibility_4</td>
  <td class="xl652966" width="336" style="border-left:none;width:252pt">Corrective_Action</td>
  <td class="xl652966" width="92" style="border-left:none;width:69pt">Action_Taken</td>
  <td class="xl652966" width="93" style="border-left:none;width:70pt">Action_Status</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">1</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">13-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">A</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.233</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">336</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">2</td>
  <td class="xl632966" style="border-top:none;border-left:none">Milling</td>
  <td class="xl632966" style="border-top:none;border-left:none">Surface Defect</td>
  <td class="xl632966" style="border-top:none;border-left:none">Ahite paches
  appear on surface</td>
  <td class="xl632966" style="border-top:none;border-left:none">Grinding</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Common Problem,
  Analysis to be requeired</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Pending</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">2</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">13-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">A</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.272</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">30</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" style="border-top:none;border-left:none">Milling</td>
  <td class="xl632966" style="border-top:none;border-left:none">Surface Defect</td>
  <td class="xl632966" style="border-top:none;border-left:none">Unclear appear on
  3.1mm slot after milling operation</td>
  <td class="xl632966" style="border-top:none;border-left:none">NPD</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Common Problem,
  Analysis to be done</td>
  <td class="xl632966" style="border-top:none;border-left:none">&nbsp;</td>
  <td class="xl632966" style="border-top:none;border-left:none">Pending</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">3</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">14-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">101</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">A</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.093</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">3</td>
  <td class="xl632966" style="border-top:none;border-left:none">Turning</td>
  <td class="xl632966" style="border-top:none;border-left:none">Chipping</td>
  <td class="xl632966" style="border-top:none;border-left:none">small chippoff on
  edge</td>
  <td class="xl632966" style="border-top:none;border-left:none">Process</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">From Next Bacth
  order Aill take care of this problem</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Pending</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">4</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">15-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">AL10</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.079</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" style="border-top:none;border-left:none">EDM</td>
  <td class="xl632966" style="border-top:none;border-left:none">Out of Dimension</td>
  <td class="xl632966" style="border-top:none;border-left:none">Side slot -0.02
  minimum side comes in milling</td>
  <td class="xl632966" style="border-top:none;border-left:none">Operators</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">No</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Not required</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">5</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">15-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">101</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">TZM</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.083</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">63</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" style="border-top:none;border-left:none">EDM</td>
  <td class="xl632966" style="border-top:none;border-left:none">Chipping</td>
  <td class="xl632966" style="border-top:none;border-left:none">small chippoff on
  edge</td>
  <td class="xl632966" style="border-top:none;border-left:none">Grinding</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Setters should be
  take care of this problem</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Completed</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl632966" align="right" style="height:15.0pt;border-top:
  none">9</td>
  <td class="xl642966" align="right" style="border-top:none;border-left:none">15-02-2021</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1137</td>
  <td class="xl632966" style="border-top:none;border-left:none">A</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">0.083</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">12345</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">63</td>
  <td class="xl632966" align="right" style="border-top:none;border-left:none">1</td>
  <td class="xl632966" style="border-top:none;border-left:none">Milling</td>
  <td class="xl632966" style="border-top:none;border-left:none">Chipping</td>
  <td class="xl632966" style="border-top:none;border-left:none">small chipoff</td>
  <td class="xl632966" style="border-top:none;border-left:none">Grinding</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">No</td>
  <td class="xl632966" style="border-top:none;border-left:none">NULL</td>
  <td class="xl632966" style="border-top:none;border-left:none">Not required</td>
 </tr>
 <!--[if supportMisalignedColumns]-->
 <tr height="0" style="display:none">
  <td width="20" style="width:15pt"></td>
  <td width="73" style="width:55pt"></td>
  <td width="35" style="width:26pt"></td>
  <td width="118" style="width:89pt"></td>
  <td width="97" style="width:73pt"></td>
  <td width="94" style="width:71pt"></td>
  <td width="102" style="width:77pt"></td>
  <td width="72" style="width:54pt"></td>
  <td width="96" style="width:72pt"></td>
  <td width="82" style="width:62pt"></td>
  <td width="117" style="width:88pt"></td>
  <td width="342" style="width:257pt"></td>
  <td width="110" style="width:83pt"></td>
  <td width="110" style="width:83pt"></td>
  <td width="110" style="width:83pt"></td>
  <td width="110" style="width:83pt"></td>
  <td width="336" style="width:252pt"></td>
  <td width="92" style="width:69pt"></td>
  <td width="93" style="width:70pt"></td>
 </tr>
 <!--[endif]-->
</tbody></table>

</div>


<!----------------------------->
<!--END OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD-->
<!----------------------------->



</body>
@fromDate,
@今天,
@depname varchar(50),
@MattypeVarchar(50),
@matnum varchar(50)
作为
选择前10名原因摘要作为原因,总和(拒收数量)作为数量
来自Semico_NPD
其中@fromDate和@toDate或Department之间的日期=@depname或Material\u Type=@mattype或Material\u Number=@matnum
按原因分组
订单总额(拒收数量)说明
身份证件
日期
物料需求计划
材料编号
材料类型
重量(单位:千克)
订单号
订单数量
拒收数量
部门
理由简介
你解释的理由
责任1
责任2
责任3
责任4
纠正措施
采取的行动
行动与地位
1.
13-02-2021
1.
1137
A.
0.233
12345
336
2.
碾磨
表面缺陷
亚硫酸盐充填
浮出水面
研磨
无效的
无效的
无效的
共同的问题,,
需要重新进行的分析
无效的
悬而未决的
2.
13-02-2021
1.
1137
A.
0.272
12345
30
1.
碾磨
表面缺陷
不清楚出现在
铣削操作后的3.1mm槽
新产品开发
无效的
无效的
无效的
共同的问题,,
需要进行的分析
悬而未决的
3.
14-02-2021
101
1137
A.
0.093
12345
12
3.
转弯
碎屑
小插页
边缘
过程
无效的
无效的
无效的
从下个星期开始
我来处理这个问题
无效的
悬而未决的
4.
15-02-2021
1.
1137
AL10
0.079
12345
12
1.
电火花加工
超出尺寸
侧槽-0.02
铣削中的最小边
操作员
无效的
无效的
无效的
不
无效的
不需要
5.
15-02-2021
101
1137
TZM
0.083
12345
63
1.
电火花加工
碎屑
小插页
边缘
研磨
无效的
无效的
无效的
二传手应该是
处理好这个问题
无效的
完整的
9
15-02-2021
1.
1137
A.
0.083
12345
63
1.
碾磨
碎屑
小切屑
研磨
无效的
无效的
无效的
不
无效的
不需要

感谢您的所有回复。我使用以下代码实现了这一功能:

@fromDate Date,
@toDate Date,
@depname varchar(50),
@mattype varchar(50),
@matnum varchar(50)
as
    select top 10 Reason_Brief as Reason, Sum(Rejection_Qty) as Quantity
    from Semicon_NPD
    Where (Date between  @fromDate  and  @toDate) and (Material_Type = IIF(ISNULL(@mattype, '') = '', Material_Type, @mattype)) and (Material_Number = IIF(ISNULL(@matnum, '') = '', Material_Number, @matnum)) and (Department = IIF(ISNULL(@depname, '') = '', Department, @depname))
    group by Reason_Brief
    order by Sum(Rejection_Qty) desc
    go

; 投票以印刷方式关闭。@Larnu感谢您提供的链接,我在将长度指定给varchar并将add with value更改为add with sqldb data type后尝试过,但问题仍然存在……好的,您现在需要花时间为我们发布一个链接,以便我们可以复制该问题。DDL和DML中的样本数据将帮助我们,不会的;我不是从谷歌硬盘下载一个陌生人的文件。把信息放在问题中,它属于哪里。