Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 02:33 PM
you have to group by just the id columns and put functions on the rest of the columns you want. See below for solution. Yeah, it's tedious.
select id, date, max(col1) as col1, max(col2) as col2, max(col3) as col3, max(col4) as col4
from table1
pivot (
max(value) as a
for key in ('col1', 'col2', 'col3', 'col4') <-- how to do this without specifying each column
)
group by id, date