[Solved] How to find average of a col1 grouping by col2 [duplicate]

With a data.frame named dat that looked like: rank name country category sales profits assets marketvalue 21 21 DaimlerChrysler Germany Consumer_dur 157.13 5.12 195.58 47.43 Try (untested d/t the numerous spaces in the text preventing read.table from making sense of it): aggregate(dat[ , c(“sales”, “profits”, “assets”, “marketvalue”)], # cols to aggregate dat[“country”], # group column … Read more

[Solved] SQL group data based on a column and pivot rows to (unknown) columns [duplicate]

A straight-up PIVOT in concert row_number() with should do the trick Select * From ( Select ID = fd_Interpretation ,Item = concat(‘Word’,row_number() over (partition by fd_Interpretation order by fd_Word) ) ,Value = fd_Word From YourTable ) src Pivot ( max( Value ) for Item in ([Word1],[Word2],[Word3],[Word4],[Word5],[Word6],[Word7],[Word8]) ) pvt 2 solved SQL group data based on … Read more