Awk to add selected row column data

Looks at the most efficient way to add up the column of data based off of the rows.

Random data
Name-Number-ID
Sarah-2.0-15
Bob-6.3-15
Sally-1.0-10
James-1.0-10
Scotty-10.7-15

So I would select all those who have ID = 15 and then add up total number

read - p "Enter ID number" Num

cut -d "-" -f 2-3 file.txt > temp.txt
awk -F "-" '/' $Num '/ {hour += $2} END {Print "Total is: " %.2f\n, number}' temp.txt

Not sure on the syntax or if hour+= should be $2 or $3:wall:

awk -F '-'  '$3==15 {sum+=$2}  END{ print sum}'  randomfile
cut -d ":" -f 2-3 works_on > temp.txt
awk -F ':'  '$3==$var3 {sum+=$2}  END{ print "Total : sum}' temp.txt 

since 15 can change then it would have to be a variable. $3 is the 3rd column correct?

I get the error
"awk: line 1: runaway string constant"

You can't have variable expansion inside single quotes. Try:

awk -F: '$3==v{sum+=$2} END{print "Total :" sum}' v="$var3" temp.txt

Your FS changed from "-" to ":" , correct?