• it is tough to give you an answer without some DDL and sample data. read the link in my sig to get better help.

    that being said possibly something like this will get you started. its not pretty and probably wont scale well.

    CREATE TABLE #temp(datefreq CHAR(7), val INT,startdate DATETIME)

    INSERT INTO #temp(datefreq,val,startdate)

    VALUES('weekly',1,'2012-01-01'),

    ('weekly',5,'2012-07-07'),

    ('weekly',10,'2013-05-31'),

    ('monthly',2,'2013-08-08'),

    ('monthly',10,'2013-07-06'),

    ('monthly',25,'2013-01-01')

    SELECT datefreq,SUM(val),CASE WHEN datefreq = 'weekly' THEN (SELECT TOP 1 val FROM #temp WHERE datefreq='Weekly' ORDER BY startdate DESC)

    WHEN datefreq = 'monthly' THEN (SELECT TOP 1 val FROM #temp WHERE datefreq='monthly' ORDER BY startdate DESC) END

    FROM #temp

    GROUP BY datefreq

    DROP TABLE #temp

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]