The pressure P1 at the top of a dam and P2 at a depth h from the top are related as:
P2−P1 = ρgh
The pressure at a point at a depth h from the top of the surface of the dam is due to the weight of the liquid acting on the point.
So, P = ρgh
where, ρ = density of the liquid
and, g = acceleration due to gravity
Also, depth h for P1 = 0 (top of the dam)
and, depth h for P2 = h
Or, P1 = ρ×g×0 = 0
And, P2 = ρgh
So, P1 and P2 are related as:
P2 - P1 =ρgh