Let \mathbb{N} denote the set of all positive integers and for j,n \in \mathbb{N}, let (j,n) denote their greatest common divisor. For any S\subseteq \mathbb{N}, we define P_{S}(n) to be the sum of those (j,n) \in S, where j \in \{1,2,3, \ldots, n\}. An asymptotic formula for the summatory function of P_{S}(n) is obtained in this paper which is applicable to a variety of sets S. Also the formula given by Bordellès for the summatory function of P_{\mathbb{N}}(n) can be derived from our result. Further, depending on the structure of S, the asymptotic formulae obtained from our theorem give better error terms than those deducible from a theorem of Bordellès (see Remark 4.4).