我有这样的桌面设计......
状态可以是=“new”,“inprogress”,“on hold”,“closed”
Activity table- ActID(PK), assignedtoID(FK), Env_ID(FK), Product_ID(FK), project_ID(FK), Status.
Product_table - Product_ID(PK), Product_name
Project_Table- Project_ID(PK), Project_Name.
Environment_Table- Env_ID(PK), Env_Name.
Employee_Table- Employee_ID(PK), Name.
Employee_Product_projectMapping_Table -Emp_ID(FK), Project_ID(FK), Product_ID(FK).
Product_EnvMapping_Table - Product_ID(FK), Env_ID(FK).
加载检查查询
首先找出分配给特定项目中每位员工的活动总数。
(A)。然后找到该项目中该员工的活动数量,其中status = new或inprogress。 (B)。划分A / B.以百分比值计算此A / B.
所以我的最终查询表输出将包含
任何人都可以帮我查询并解释如何实现这一结果吗?谢谢。
到目前为止,我已经尝试了很多...得到A和B的结果,但现在我需要将这两个结合起来...
(A).
SELECT activity_table.assignid, activity_table.projid, Count(activity_table.actid) AS CountOfactid
FROM activity_table
GROUP BY activity_table.assignid, activity_table.projid;
(B).
SELECT activity_table.assignid, activity_table.projid, Count(activity_table.actid) AS CountOfactid
FROM activity_table where status in ('new','inprogress')
GROUP BY activity_table.assignid, activity_table.projid ;
答案 0 :(得分:0)
这是第3个结果......不是第4个结果。
select Employee_table.name,Project_table.Project_Name, Count(activity_table.actid) AS CountOfactid
from Activity table,Employee_Table,Project_Table,Employee_Product_projectMapping_Table
where Activity_Table.Product_Id=Project_Table.Product_Id
and
aage ka syntax yaad nai aa raha hai...
Employee_Product_projectMapping_Table aur Employee_Table ko combine karke emp name through equating product id...
为第4个使用嵌套查询......
将尝试解决此查询asap .....:P
409008 ...