sql server 2008 - How to sort before using STUFF in SSRS -




i have 2 different values i'm trying stuff here. quantity + price. example: 1-$0.36; 100-$0.29; 25-$0.31. how can have sort quantity before being stuffed? (1,25,100 instead of 1,100,25) did come across link sort data before concatenating using stuff xml, dealt 1 value , i'm dealing 2 values

    select stuff(    (select distinct top (5)          '; ' + (cast(floor(case when pcfbd.quantity not null pcfbd.quantity else 1 end) varchar)  + '-$' + cast(replace(replace(rtrim(replace(        case when pcf.pricemethod = 0 round(i.cdcost / (100 - pcf.formulapercent) * 100, 2)              when pcfbh.priceformula = 2 , pcfbd.formulapercent null round(i.cdcost / (100 - pcf.formulapercent) * 100, 2)             when pcfbh.priceformula = 2 , pcfbd.formulapercent not null round(i.cdcost / (100 - pcfbd.formulapercent) * 100, 2)             when pcfbh.priceformula = 1 round((i.listprice * (100 - pcfbd.formulapercent)) * .01,2)             else null end, '000' ,'')), ' ','0') + '', '.  ', '') varchar))               item   inner join        pricecontractfamily pcf on i.familyid = pcf.familyid                  , i.itemstatus in (0, 5)   inner join        stockitem si on i.itemid = si.itemid                  , si.warehouseid = '502e5876-c26b-4e11-8b88-afe0c34ecf0d'                       left outer join   pricecontractfamilybracketheader pcfbh on pcf.pricecontractfamilyid = pcfbh.pricecontractfamilyid   left outer join   pricecontractfamilybracketdetail pcfbd on pcfbh.bracketheaderid = pcfbd.bracketheaderid  i.listprice = @listprice , left(i.itemnumber, 6) = @itemnumber , pcf.pricecontractid = @pricecontractid    xml path('')),1, 2, '') qtyprice                                                         

you should able add order before xml path statement.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -