Absolutely the best advice for that question.
@Aurora09, if you do this you will see that P2 - P1 = pgHf (where Hf is frictional head loss), is obtained for z1 = z2 and d1 = d2 where d is the pipe ID.
Extended Bernoulli can also address your other questions regarding sloped and vertical pipes.