• thank you for your replies. I wiil read them.

    how about something like the following(using CTE):

    declare @dataBegin datetime;

    declare @dataEnd datetime;

    set @dataEnd = '21/05/2013';

    set @dataBegin = DATEADD(month,-11, @dataEnd) - (DAY(@dataEnd)-1);

    set @dataEnd = DATEADD(month,1, @dataEnd) - (DAY(@dataEnd));

    WITH dates AS

    (

    SELECT CAST(@dataBegin AS DATETIME) 'date'

    UNION ALL

    SELECT DATEADD(MONTH, 1, t.date)

    FROM dates t

    WHERE DATEADD(month, 1, t.date) <= @dataEnd

    )

    select month(dates.date) as mese, YEAR(dates.date) as anno,department

    from dates

    ,

    (

    SELECT distinct department

    FROM T1

    ) t2

    the result is that i have all the dates i need with the departments but i need to join this result with

    SELECT department,SUM(totalsales) AS totsales, MONTH(dateofsale) as month, YEAR(dateofsale) as year

    FROM T1

    WHERE dateofsale >= @dataBegin AND dateofsale< @dataEnd

    GROUP BY department,MONTH(dateofsale), YEAR(dateofsale)

    ORDER BY department,MONTH(dateofsale), YEAR(dateofsale)

    the problem is that i cant do this join...

    any idea?

    thank's again