0

プロジェクトに費やした合計時間を月ベースで表示する SQL ステートメントを作成しようとしています。誰かが SQL クエリを手伝ってくれますか?

SELECT Projects.projectID,
        Projects.projectName,
        billingsTimes.actualTotalTime,
        billingsTimes.taskID,
        Tasks.taskName
  FROM Projects_tasks
       INNER JOIN Projects ON Projects_tasks.projectID = Projects.projectID
       INNER JOIN Tasks ON Projects_tasks.taskID = Tasks.taskID
       INNER JOIN billingsTimes ON Tasks.taskID = billingsTimes.taskID

ここに画像の説明を入力

DB図

4

2 に答える 2

0

これは機能しますか?:

SELECT  Projects.projectID,
        Projects.projectName,
        SUM(billingsTimes.actualTotalTime),
        billingsTimes.taskID,
        Tasks.taskName, 
        MONTH(billingTimes.createdOn),
        YEAR(billingTimes.createdOn)
FROM    Projects_tasks
        INNER JOIN Projects ON Projects_tasks.projectID = Projects.projectID
        INNER JOIN Tasks ON Projects_tasks.taskID = Tasks.taskID
        INNER JOIN billingsTimes ON Tasks.taskID = billingsTimes.taskID
GROUP BY
        Projects.projectID,
        Projects.projectName,
        billingsTimes.taskID,
        Tasks.taskName, 
        MONTH(billingTimes.createdOn),
        YEAR(billingTimes.createdOn)
于 2012-09-13T19:14:01.757 に答える
0
select p.projectID,
    p.projectName,
    year(bt.createdOn) as Year,
    month(bt.createdOn) as Month,
    sum(bt.actualTotalTime) as TotalTime
from Projects_tasks pt
inner join Projects p on pt.projectID = p.projectID
inner join Tasks t on p.taskID = t.taskID
inner join billingsTimes bt on t.taskID = bt.taskID
group by p.projectID,
    p.projectName,
    year(bt.createdOn),
    month(bt.createdOn),
于 2012-09-13T19:15:42.633 に答える