SQL Server 2008にコードがあり、別の行に参加する必要があります。 SQL Server:1行に2行
この
はコードselect
usuario.SK_Representative,
sum(devo.NM_Material) as deve
from
DW_DTS_Representative usuario
inner join
DIS_DTS_Sales_Return_Fact devo on devo.SK_Representative = usuario.SK_Representative
inner join
DW_DTS_Operation_Nature cfop on cfop.SK_Operation_Nature = devo.SK_Operation_Nature
inner join
DW_DTS_Emitter cli on cli.SK_Emitter = devo.SK_Emitter
where
devo.CD_Currency = '0'
and devo.CD_Site = '001'
and cli.CD_Customer_Group = '10'
and usuario.SK_Representative != '2'
and usuario.SK_Representative != '3'
and usuario.SK_Representative != '4'
and usuario.SK_Representative != '41'
and usuario.SK_Representative != '48'
and usuario.SK_Representative != '49'
and usuario.SK_Representative != '43'
and devo.DT_Day between DateAdd(yyyy, DateDiff(yyyy,0,GetDate()), 0)
and dateadd([month], datediff([month], '18991231', dateadd(month, -1, getdate())), '18991231')
group by
usuario.SK_Representative
ある
そのスクリプトの結果は次のとおりです。
しかし、私はのためのSK_Representativeに番号「33」のSK_Representative情報を集約する必要があります番号「47」。私はSK_Representativeである主キーを失うことなくこれを行う必要があります。
これは現在の結果または欲しい出力ですか? –
"番号33のSK_Representative情報を番号 '47'のSK_Representativeに集約する" –
SK_Representative '33'の 'deve'値はSK_Representative '47'の 'deve'と合計する必要があります –