In reply to dave_59:
According to what I understand it works as below. Please do correct me where am I going wrong.
rand bit [7:0] a [2][3];
constraint a_r_c {
foreach (a[i,j]) {
a[i].sum() with (int'(item)) == 3; // a[0][0] + a[0][1] + a[0][2] == 3
// a[1][0] + a[1][1] + a[1][2] == 3
a.sum() with (int'(a[item.index][j])) == 3; // a[0][0] + a[1][0] == 3
// a[0][1] + a[1][1] == 3
// a[0][2] + a[1][2] == 3
}