本文介绍了如何添加SQL总结的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样一种情况:从这张桌子:

|名称|数量|序列号|

|监视器| 1 | ADJ1DAJAK |

|监视器| 1 | AMBJA1ASL |





我的列表视图一直被视为:

|数量可用|名称|

| 2 |监控|



现在,即我将两台监控器添加到请购单表中。麻烦的是,它在数据网格视图中显示为:

|数量可用|名称|

| 2 |监控|



但我真正想要的是它在我的数据网格视图中显示为:

|名称|数量|序列号|

|显示器| 1 | ADJ1DAJAK |

|显示器| 1 | AMBJA1ASL |



使用的查询:

I have a situation where from this table:
|Name |Qty|serial|
|Monitor |1 |ADJ1DAJAK |
|Monitor |1 |AMBJA1ASL |


It's been viewed as this by my listview:
|Qty Available|Name |
| 2 |Monitor |

Now, i.e. I add two monitors to a requisition table. The trouble is, it is shown on the data grid view as this:
|Qty Available|Name |
| 2 |Monitor |

but what I really want is that for it to be shown as this in my data grid view:
|Name |Qty|serial|
|Monitor |1 |ADJ1DAJAK |
|Monitor |1 |AMBJA1ASL |

Used Query:

SELECT 
    SUM(Supp_Qty) AS Quantity,
    Supp_ProdName,
    Supp_UMeasure,
    Supp_Desc,
    Supp_LotBatch, 
    Supp_ProdBrand, 
    Supp_SuppName, 
    Supp_ID 
FROM 
    `supply_record` 
WHERE 
    Supply_type = 'Assets' 
GROUP BY 
    Supp_ProdName





我是什么尝试过:



没有真正尝试过任何事情因为我真的不知道该怎么做。请帮助。



What I have tried:

Haven't really tried anything since I don't really know what to do. Please help.

推荐答案

SELECT 
    SUM(Supp_Qty) AS Quantity,
    Supp_ProdName,
    Supp_UMeasure,
    Supp_Desc,
    Supp_LotBatch, 
    Supp_ProdBrand, 
    Supp_SuppName, 
    Supp_ID 
FROM 
    `supply_record` 
WHERE 
    Supply_type = 'Assets' 
GROUP BY 
    Supp_ProdName,
    Supp_UMeasure,
    Supp_Desc,
    Supp_LotBatch, 
    Supp_ProdBrand, 
    Supp_SuppName, 
    Supp_ID 





希望有所帮助^ _ ^

Andy



Hope that helps ^_^
Andy


while(i < qty)
                  {
                      con.Close();


                      MySqlCommand cmd = new MySqlCommand("insert into suppreq_temp(Req_Desc, Req_Brand, Req_Qty, Req_Supplier, RIS_DATE, Req_Date, Person_Incharge, Section_Belong, Tempcnt, Req_Serial) values ('" + txtProdName.Text + "', '" + txtProdBrand.Text + "', '" + txtQty.Text + "', '" + txtSupp.Text + "', '" + reqdate.Text + "', '" + dtprealdate.Text + "','" + txtPerson.Text + "','" + SecCombo.Text + "', '" + txtID.Text + "', '" + dataGridView3.Rows[i].Cells[0].Value.ToString() + "')", con.con);
                      con.Open();
                      reader = cmd.ExecuteReader();
                      
                      con.Close();
                      
                      i++;
                  }


这篇关于如何添加SQL总结的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 09:09