> >SELECT acc_code,sum(open_dr) as dr_amount,sum(open_cr) as cr_amount > from master where LEN(acc_code)>4 and left(acc_code,4)='2305' > group by acc_code > >>
>SELECT acc_code,sum(open_dr) as dr_amount,sum(open_cr) as cr_amount > from master where LEN(acc_code)>4 and left(acc_code,4)='2305' > group by LEFT(acc_code,2)='23' >>
select min(acc_code) + '-' + max(acc_code) as AccountRanges, sum(open_dr) as dr_Amount, sum(open_cr) as cr_Amount from dbo.master where acc_code like '2305%' and len(acc_code) > 4The above will generate a single row showing the range of accounts. If you want to list all accounts in a single row, that query will need to be slightly modified.