select event_id, sum(distance_in_miles) as this_month,
convert(varchar,dateadd(ss, sum(time_h)*3600+sum(time_m)*60+sum(time_s), '2008-01-01 00:00:00.000' ),108)
where event_date between DATEADD(day,-(DAY(GETDATE())),GETDATE()) and GETDATE()
and contact_id=45 and validity='Y'
group by event_id
order by event_id
Let us know.
Kalman Toth - Database, Data Warehouse & Business Intelligence Architect
The Best SQL Server 2005 Training in the World!