Ah super Tipp mit dem Case / Then
Habe es ein klein wenig meinen Bedürfnissen angepasst:
SQL-Code:
Select ActivityDate,
SUM(CASE FK_ActivityTypeID WHEN 1 THEN TimeSpan ELSE 0 END) AS 'BillableHours',
SUM(CASE WHEN FK_ActivityTypeID <> 1 THEN TimeSpan ELSE 0 END) AS 'NonBillableHours',
SUM(Timespan) as TotalTime
FROM TB_AM_Hours
WHERE
FK_UserID = 1
and ActivityDate >= '03.03.2008 00:00:00'
and ActivityDate <= '09.03.2008 00:00:00'
and FK_ProgramID = 1
group by ActivityDate;