Quote:
SELECT
(
SELECT
IsNull(l.i_amt-Sum(r.cheque_amount), l.i_amt),
l.im_id
FROM
tbl_ib_cus_libility l
LEFT JOIN tbl_received R ON r.li_id = l.li_id
WHERE
l.im_id=14
AND
(l.i_status = 1 OR l.i_status IS NULL)
AND
l.l_delid IS NULL
AND
l.li_id <
(
SELECT Max(sub.li_id)
FROM tbl_ib_cus_libility AS sub
)
GROUP BY
l.im_id,
l.i_amt
) as Balance,
The error is caused by this line. You are selecting two columns and trying to return them in a single column.
The
GROUP BY
clause also suggests that you're expecting this to return multiple rows. That won't work - you can only return a single row containing a single column.
It's not clear exactly what you're trying to achieve here.