  Let $D$ be a subset of a finite commutative ring $R$ with identity. Let
$f(x)\in R[x]$ be a polynomial of positive degree $d$. For integer $0\leq k
\leq |D|$, we study the number $N_f(D,k,b)$ of $k$-subsets $S\subseteq D$ such
that
  \begin{align*}
  \sum_{x\in S} f(x)=b.
  \end{align*} In this paper, we establish several asymptotic formulas for
$N_f(D,k, b)$, depending on the nature of the ring $R$ and $f$.
  For $R=\mathbb{Z}_n$, let $p=p(n)$ be the smallest prime divisor of $n$,
$|D|=n-c \geq C_dn p^{-\frac 1d }+c$ and $f(x)=a_dx^d +\cdots +a_0\in
\mathbb{Z}[x]$ with $(a_d, \dots, a_1, n)=1$. Then
  $$\left| N_f(D, k, b)-\frac{1}{n}{n-c \choose k}\right|\leq
  {\delta(n)(n-c)+(1-\delta(n))(C_dnp^{-\frac 1d}+c)+k-1\choose k},$$ partially
answering an open question raised by Stanley \cite{St}, where
$\delta(n)=\sum_{i\mid n, \mu(i)=-1}\frac 1 i$ and $C_d=e^{1.85d}$.
Furthermore, if $n$ is a prime power, then $\delta(n) =1/p$ and one can take
$C_d=4.41$.
  For $R=\mathbb{F}_q$ of characteristic $p$, let $f(x)\in \mathbb{F}_q[x]$ be
a polynomial of degree $d$ not divisible by $p$ and
  $D\subseteq \mathbb{F}_q$ with $|D|=q-c\geq (d-1)\sqrt{q}+c$. Then $$\left|
N_f(D, k, b)-\frac{1}{q}{q-c \choose k}\right|\leq {\frac{q-c}{p}+\frac
{p-1}{p}((d-1)q^{\frac 12}+c)+k-1 \choose k}.$$
  If $f(x)=ax+b$, then this problem is precisely the well-known subset sum
problem over a finite abelian group. Let $G$ be a finite abelian group and let
$D\subseteq G$ with $|D|=|G|-c\geq c$. Then $$\left| N_x(D, k,
b)-\frac{1}{|G|}{|G|-c \choose k}\right|\leq {c + (|G|-2c)\delta(e(G))+k-1
\choose k},$$ where $e(G)$ is the exponent of $G$ and $\delta(n)=\sum_{i\mid n,
\mu(i)=-1}\frac 1 i$. In particular, we give a new short proof for the explicit
counting formula for the case $D=G$.
