我有一個記錄事件的表,因此它可以多次記錄相同的ID。我想爲每個唯一的RefID返回單行,因爲'Y'在相關列中被替換爲'N'。下面是一個模擬式Sql中不同的行
DECLARE @Ref TABLE
(
RefID INT
, InvoiceNo INT
, InvoicedDate Date
, CustID INT
, PaidOnTime CHAR(1)
, Paidlate CHAR(1)
, PaidByCash CHAR(1)
, PaidByCard CHAR(1)
)
INSERT INTO @Ref VALUES
(23,50,'22-jun-2015', 11,'Y','N','Y','N')
, (23,50,'22-jun-2015', 11,'Y','N','N','Y')
, (27,11,'12-Aug-2015', 11,'Y','N','N','Y')
, (27,11,'22-Aug-2015', 11,'N','Y','N','Y')
, (45,67,'28-jun-2015', 11,'N','Y','Y','N')
, (45,67,'28-jun-2015', 11,'N','N','N','Y')
, (48,51,'18-jun-2015', 11,'Y','N','Y','N')
SELECT * FROM @Ref --would return values like so:
例如,23 REFID應該是 「23,50,22/06/2015,11,Y,N,Y,Y」
相同的輸出輸入? – jarlh
看看羣體和獨特。他們應該掩護你。 –
獨特和集團條款不會處理這 – dLight