我一直在查詢如下。 (我使用VB.NET 2010和DB是2007 MSACCESS)如何分隔行按sql查詢分組
SELECT
sale_details.invoiceno AS sale_details_invoiceno,
sale_details.product_code,
sale_details.qty, sale_details.totalkg, sale_details.Rate, sale_details.subtotal,
sale_head.invoiceno AS sale_head_invoiceno, sale_head.suppliername, sale_head.invoicedate
FROM
sale_head
INNER JOIN
sale_details ON sale_head.[invoiceno] = sale_details.[invoiceno]
WHERE
(((sale_head.suppliername)='Ramkrishna Creation'));
其中顯示結果如下:
sale_details_invoice|product_code|qty |totalkg|Rate |Subtotal|Sale_head_invoice|suppliername |invoicedate
5026 | M 1010 | 10 | 2.5 | 270 | 675 |5026 |Ramkrishna Creation | 18/07/2014
5026 | CHIKU | 100| 25 | 500 | 12500 |5026 |Ramkrishna Creation | 18/07/2014
5026 | F PINK | 50 | 12.5 | 500 | 6250 |5026 |Ramkrishna Creation | 18/07/2014
4002 | LJ 16 | 80 | 12 | 350 | 4200 |4002 |Ramkrishna Creation | 10/08/2014
4002 | BCH 950 | 50 | 12.5 | 150 | 1875 |4002 |Ramkrishna Creation | 10/08/2014
3598 | L COPPER | 150| 37.5 | 500 | 18750 |3598 |Ramkrishna Creation | 10/08/2014
3598 | BCH 950 | 50 | 12.5 | 150 | 1875 |3598 |Ramkrishna Creation | 10/08/2014
3598 | CHIKU | 100| 25 | 500 | 12500 |3598 |Ramkrishna Creation | 18/07/2014
我想打破和發票顯示總NO。 SQL或VB.NET DataGrid控件中是否有任何方式顯示如下所示的結果?
sale_details_invoice|product_code|qty |totalkg|Rate |Subtotal|Sale_head_invoice|suppliername |invoicedate
5026 | M 1010 | 10 | 2.5 | 270 | 675 |5026 |Ramkrishna Creation | 18/07/2014
5026 | CHIKU | 100| 25 | 500 | 12500 |5026 |Ramkrishna Creation | 18/07/2014
5026 | F PINK | 50 | 12.5 | 500 | 6250 |5026 |Ramkrishna Creation | 18/07/2014
TOTAL 19425
4002 | LJ 16 | 80 | 12 | 350 | 4200 |4002 |Ramkrishna Creation | 10/08/2014
4002 | BCH 950 | 50 | 12.5 | 150 | 1875 |4002 |Ramkrishna Creation | 10/08/2014
TOTAL 6075
3598 | L COPPER | 150| 37.5 | 500 | 18750 |3598 |Ramkrishna Creation | 10/08/2014
3598 | BCH 950 | 50 | 12.5 | 150 | 1875 |3598 |Ramkrishna Creation | 10/08/2014
3598 | CHIKU | 100| 25 | 500 | 12500 |3598 |Ramkrishna Creation | 18/07/2014
TOTAL 33125
有沒有辦法通過SQL或VB.NET DataGrid控件來解決這個問題?我一直在尋找解決方案,但我還沒有得到它,請大家如果你知道,請讓我知道
使用GROUPBY發票ID ... – Codexer 2014-09-01 13:30:37
能否請您寫完整的查詢嗎? – 2014-09-01 13:49:15
添加這個:GroupBy sale_details.invoiceno在你的where子句後 – Codexer 2014-09-01 13:57:45