I have the following table
and I need this query result
I basically have to make a "unique" value from the columns Nr and S. Then I need to group by this new unique value.
How do I do this.
I have the following table
and I need this query result
I basically have to make a "unique" value from the columns Nr and S. Then I need to group by this new unique value.
How do I do this.
starting from SQL Server 2017 you could use string_agg
select id, concat(nr,'-',s) nr_s, k, s
, STRING_AGG(z_value, ';') z_value
, STRING_AGG(x_value, ';') x_value
, STRING_AGG(y_value, ';') y_value
from my_table
group by id, concat(nr,'-',s), k, s