join with sum and group by
I have two tables. They're in a 1:N relationship.
Tasks - Id - Name
Report - Id - Time - TaskId -FK
I'd like to create a query which will sum the report time by a task.
I tried this,but its not working
SELECT NAME,SUM (TIME) FROM开发者_运维技巧 TASKS LEFT JOIN REPORT ON TASKS.ID = REPORT.TASKID
GROUP BY TASKS.NAME
Its Oracle and with this query the time column is null in the result.
SELECT
NAME,
SUM( ISNULL(TIME, 0) ) SumOfTime /* Time could be NULL! */
FROM
TASKS
LEFT JOIN REPORT ON TASKS.ID = REPORT.TASKID
GROUP BY
TASKS.NAME
精彩评论