on 2019 Nov 13 11:06 AM
I use this example for dynamic number of columns with pivot. But how do I remove quotes around the column names?
begin create or replace variable @props varchar(120) array; select * into #propdata from sp_property_history(); set @props = ( select array_agg( distinct name order by name ) from #propdata ); select * from ( select name, ticks, time_recorded, time_delta, value_delta from #propdata ) mysourcedata pivot ( sum( value_delta ) delta for name in @props ) mydata order by ticks desc; end;
User | Count |
---|---|
79 | |
11 | |
10 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.