This is my first post and I am new to SQL
I have a table like
H Amount Count ID
h1 2 1 x
h2 3 2 x
h3 5 3 x
h1 3 3 x
h1 1 5 y
h2 3 2 x
h3 1 1 x
h3 2 3 y
h2 5 5 y
and I want SUM(Amount*Count) of each H group based on id / Total SUM(Amount*Count) in that H group
i.e
H value ID
h1 11/16 x value = (2*1+3*3)/2*1+3*3+1*5
h1 5/16 y value = 1*5/ 2*1+3*3+1*5
h2 12/37 x
h2 25/37 y
h3 16/22 x
h3 6/22 y
My aim is to group by H and then on EACH GROUP I have to do - Sum(average*count) Over(partition by ID) / Sum(average*count)
but I am not able to write such query can you guys please help me. And sorry about the formatting Thanks