SQL添加新列,在其他列中划分数字

时间:2017-02-20 08:59:45

标签: sql ms-access access-vba ms-access-2010

我一直试图操作此代码一段时间但无济于事 - 感谢任何帮助:

我有一个列表框,其中有两列带有数字(数据来自查询。在列表框中,我想添加第三列,将第二列除以第一列。

我的代码:

    SELECT 
     Q_Manager_CHS_Total.tbl_CEAR_Name.CEAR_Team
     T1.Q_Manager_Backlog_Total.Backlogs
     Q_Manager_CHS_Total.CHS_Total

      (T1.Q_Manager_Backlog_Total.Backlogs/Q_Manager_CHS_Total.CHS_Total) AS AverageNumber
FROM 
     Q_Manager_CHS_Total
INNER JOIN (SELECT Q_Manager_Backlog_Total.Backlogs, tbl_CEAR_Name.CEAR_Team 
INNER JOIN tbl_CEAR_Name ON Q_Manager_Backlog_Total.CEAR_Team = tbl_CEAR_Name.CEAR_Team) AS T1 
ON Q_Manager_CHS_Total.CEAR_Team = T1.CEAR_Team
ORDER BY T1.Q_Manager_Backlog_Total.Backlogs DESC;

任何帮助我们努力工作的人都会受到赞赏。

更新:下面的SQL工作并显示两列,它添加了我似乎无法做的第三列。

    SELECT Q_Manager_CHS_Total.tbl_CEAR_Name.CEAR_Team, T1.Q_Manager_Backlog_Total.Backlogs, Q_Manager_CHS_Total.CHS_Total
FROM Q_Manager_CHS_Total INNER JOIN (SELECT Q_Manager_Backlog_Total.Backlogs, tbl_CEAR_Name.CEAR_Team FROM Q_Manager_Backlog_Total INNER JOIN tbl_CEAR_Name ON Q_Manager_Backlog_Total.CEAR_Team = tbl_CEAR_Name.CEAR_Team) AS T1 ON Q_Manager_CHS_Total.CEAR_Team = T1.CEAR_Team
ORDER BY T1.Q_Manager_Backlog_Total.Backlogs DESC;

1 个答案:

答案 0 :(得分:0)

SELECT Q_Manager_CHS_Total.tbl_CEAR_Name.CEAR_Team, T1.Q_Manager_Backlog_Total.Backlogs, Q_Manager_CHS_Total.CHS_Total, T1.Q_Manager_Backlog_Total.Backlogs/Q_Manager_CHS_Total.CHS_Total AS percentage
FROM Q_Manager_CHS_Total INNER JOIN (SELECT Q_Manager_Backlog_Total.Backlogs, tbl_CEAR_Name.CEAR_Team FROM Q_Manager_Backlog_Total INNER JOIN tbl_CEAR_Name ON Q_Manager_Backlog_Total.CEAR_Team = tbl_CEAR_Name.CEAR_Team)  AS T1 ON Q_Manager_CHS_Total.CEAR_Team = T1.CEAR_Team
ORDER BY T1.Q_Manager_Backlog_Total.Backlogs DESC;