3
我有一組記錄排序(Order BY)ProductDesc,RecDate,然後ProductBrand ,它給了我下面的結果。Sql Select Order Issue
- >> SQL是
SELECT RecDate, ProductDesc,ProductBrand
FROM MyTable i
Order BY i.ProductDesc, i.RecDate,i. ProductBrand
-
RecDate --- ProductDesc --- Brand
--------------------------------------------------------------
2017-07-15 --- TOMATO ROMA --- (S & S)
2017-07-16 --- TOMATO ROMA --- (A & B)
2017-07-17 --- TOMATO ROMA --- (C & D)
2017-07-18 --- TOMATO ROMA --- (AAA)
2017-07-25 --- TOMATO ROMA --- (C & D)
2017-07-26 --- TOMATO ROMA --- (C & D)
,但我的要求是,以顯示這些記錄由ProductDesc,RecDate在ASC排序,然後如果有相同的產品用(如'TOMATE ROMA(C & D)'),但接收日期不同, 需要將它們組合在一起。排序後的數據應該如下所示
RecDate --- ProductDesc --- Brand
----------------------------------------------------------------
2017-07-15 --- TOMATE ROMA --- (S & S)
2017-07-16 --- TOMATE ROMA --- (A & B)
2017-07-17 --- TOMATE ROMA --- (C & D)
2017-07-25 --- TOMATE ROMA --- (C & D)
2017-07-26 --- TOMATE ROMA --- (C & D)
2017-07-18 --- TOMATE ROMA --- (AAA)
任何建議我如何能夠實現這一點? 注意:我正在使用SQL SERVER,並運行sql填充dataTable,並用此數據表填充datagridview。
這個解決方案工作正常..謝謝 能否請你建議我怎麼能得到與LINQ做一樣的嗎? – Ronjon
是否有可能對linq或數據表做同樣的事情? – Ronjon