0
使用SQL Server 2005顯示結果水平
我想水平有itemid, deliverydate, remainpurchphysical
顯示。
目前我使用的FOR XML PATH
和工作原理。
當結果是每itemid的多個交貨日期我想要讓他們更好地顯示了一下
[ITEMID] [DELIVERYDATE AND REMAINPURCH]
-----------------------------------------
[1234] [14/14/2014 25 | 15/15/2015 27 | 16/16/2016 28]
最好用|每個日期
之間。這裏是當前的代碼
-select itemid, CONVERT(NVARCHAR, deliverydate, 103),remainpurchphysical
--from purchline where purchstatus =1 --and itemid = '00727-s'
SELECT
itemid
,deliverydates = STUFF(
(SELECT ' ' + CONVERT(NVARCHAR, deliverydate, 103)
FROM purchline b
WHERE b.itemid = a.itemid AND purchstatus = 1
ORDER BY deliverydate
FOR XML PATH('')), 1, 1, '')
,remainpurchphysical = STUFF(
(SELECT ' ' + CAST(CONVERT(Decimal(9,0), remainpurchphysical) AS VARCHAR)
FROM purchline b
WHERE b.itemid = a.itemid AND purchstatus = 1
ORDER BY deliverydate
FOR XML PATH('')), 1, 1, '')
FROM purchline a
WHERE purchstatus =1
GROUP BY itemid
ORDER BY itemid
這裏是當前的代碼 – Makdaddy 2013-02-12 05:08:00
_where_是當前的代碼? – 2013-02-12 05:08:57
我編輯過你的標題。請參見「[應的問題包括‘標籤’,在他們的頭銜?(http://meta.stackexchange.com/questions/19190/)」,這裏的共識是「不,他們不應該」。 – 2013-02-12 05:09:30