I know this has been asked before but I've looked at other questions and my query still won't work. I have a table with MLB batting stats from last 100 years or so, I am trying to find the playerid, homeruns and percentage of that year's (2012) total homerun's hit that player's hrs make up.
query:
select playerid, hr, hr/sum(hr) over (partition by playerid, yearid)*100 p
from mlbbattingstats
where yearid=2012 and p != 0
order by hr;
error:
Error at line 3:
ORA-00904: "P": invalid identifier
I have tried multiple different aliases and gotten the same error. Any help in what I am doing wrong would be appreciated and sorry if this has been answered previously.