Simplifying awk script using multiple "|"

I have the following script:

 awk -F "," '{ if ( $4 > 450 && $4 < 550 && $5 > 0.5 ) print $2, $5; else print $2, "0" }' test.txt | awk '{a[$1]+=$2}END{for(i in a){print i, a}}' | sort -nk 1.2 | sed 1,2d
 

and a bunch of files that look like the test file attached here.
I am outputting all entries where the value meets the following parameters; $4 > 450 && $4 < 550 && $5 > 0.5 . Then I sort it and eliminate the first two rows. The scripts works well but I am pretty sure I can avoid using all the | .
Any help will be greatly appreciated
PS. I am including my output file too

one way - lightly validated:

 awk -F "," 'FNR>1{ if ( $4 > 450 && $4 < 550 && $5 > 0.5 ) a[$2]+=$5; else a[$2]+=0 }END {for (i in a) print i,a}' TEST.txt | sort -nk 1.2
1 Like

As the $2 values seem already sorted, try also

awk -F "," '$5 > 0.5 && ($4-500)^2 < 2500 {if (!T[$2]) S[++CNT]=$2; T[$2]+=$5} END {for (i=2; i<=CNT; i++) print S, T}' 

(may run into trouble if $5 equals 0)