如何将两个不同查询的结果相乘

时间:2015-05-08 02:45:19

标签: sql sql-server

我有三个表:Employee,BillingRates和WorkHours。

Employees
------------------------------
EmpID | name | titleID | level  

BillingRates
----------------------
titleID | level | rate

WorkHours
-------------------
EmpID | HoursWorked

此查询为我提供了每位员工的姓名和费率:

select 
    firstname, lastname, rate
from employees 
left join billingrates
    on employees.TitleID = BillingRates.TitleID
    and employees.Level = BillingRates.Level

这给了我EmpID和该员工的总工作时间:

select 
    employees.EmpID, sum(workhours.hoursworked) as TotalHours
from employees 
inner join workhours
    on employees.empid = WorkHours.EmpID
where 
    WH_Month = 4
group by 
    LastName, firstname, employees.EmpID  

我需要将费率输出乘以该员工的总工作小时数 有人能够协助编写生成该输出的查询吗?

1 个答案:

答案 0 :(得分:3)

您可以在SQL server

中执行类似的操作
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    LinearLayout linearLayout = (LinearLayout) findViewById(R.id.parent);
    linearLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);

    final View listView = findViewById(R.id.list_view);
    View titleRow = findViewById(R.id.titleRow);

    titleRow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ViewGroup.LayoutParams params = listView.getLayoutParams();
            params.height = params.height == 0 ? ViewGroup.LayoutParams.WRAP_CONTENT : 0;
            listView.setLayoutParams(params);
        }
    });
}