• I'm sorry Hemal, there is a slight error in my query. If there is data for more than one year then the data would be grouped only according to month only and not by year. The following is the edited query:

    Select p.Month, SUM(p.cramount) As Credit, SUM(q.dramount) As Debit From

    (

    Select b.voucherno, DATENAME(YY, a.dt) As Year, DATENAME(MM, a.dt) As Month, SUM(b.cramount) As cramount From voucher As a

    JOIN voucherCr As b ON a.voucherno = b.voucherno AND a.vouchertype = b.vouchertype

    Group By b.voucherno, DATENAME(YY, a.dt), DATENAME(MM, a.dt)

    ) As p

    JOIN

    (

    Select b.voucherno, DATENAME(YY, a.dt) As Year, DATENAME(MM, a.dt) As Month, SUM(b.dramount) As dramount From voucher As a

    RIGHT JOIN voucherDr As b ON a.voucherno = b.voucherno AND a.vouchertype = b.vouchertype

    Group By b.voucherno, DATENAME(YY, a.dt), DATENAME(MM, a.dt)

    ) As q ON p.voucherno = q.voucherno

    Group By p.Month

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉