0

I have this query

select * 
from tmp_vendor_style_no_20210104
order by vendor_style_no, serial_count desc 

which returns an output like this:

enter image description here

but I want the result to look like this instead:

enter image description here

Rows are not fixed it can be 1,2 or many more.

Thanks in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dev
  • 357
  • 2
  • 11
  • Do you have a fixed number of rows, or unknown? For the latter you will need dynamic SQL – Charlieface Jan 04 '21 at 15:55
  • Does this answer your question? [SQL Server dynamic PIVOT query?](https://stackoverflow.com/questions/10404348/sql-server-dynamic-pivot-query) – Charlieface Jan 04 '21 at 21:02

1 Answers1

-2

I thing the best way to accomplish that is using pivot function in SQL. You have to identify the column of preference to set the record values.