sql server - Pivoting rows into a Query -


hi wondering if doing possible , if if can help?

i have query several columns , on table there column several different reasons why there exclusion. want pivot column beside orginal query have 3 exclusion reasons pivoted out , display x in whichever pivoted column reason exclusion.

1) source data 2 tables in sql server

2)expected result

broker date       excluded no_activity no_money no_credit 123    11/11/16   yes            x   124    11/11/16   yes                      x 125    11/11/16   yes                                x 

3) tried

select distinct pt.brk_id 'broker', pt.dte 'date', pt.exclud 'excluded' broker_t pt left join exclusion_t et on et.dte = pt.dte  select  'x' 'no_activity', 'x' 'no_money', 'x' 'no_credit' (select excl_dcs exclusion_t) t  pivot ( max(excl_dcs) excl_dcs in ("no_activity", "no_money", "no_credit" ) piv 

4) current output

  broker date       excluded      123    11/11/16   yes                 124    11/11/16   yes                125    11/11/16   yes       no_activity no_money no_credit       x        x        x 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -