使用2个关键字段在两个字段上选择Sum [英] Select Sum on two fields using 2 key fields

查看:68
本文介绍了使用2个关键字段在两个字段上选择Sum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含十几个字段的tblWork。

它跟踪一次为2名员工工作的小时数。

- fldDriverID

- fldDriverHours

- fldHelperID

- fldHelperHours


它还有一个日期字段(fldDate)和一个键工作票据是在(fldTicketID)上执行的。


所以我指定了驱动程序和工作小时数(1,15h)对于助手(1,13h)


我想做的是做一个工资单选择,它将为每位员工提供DriverHours和HelperHours。这很容易,但困难的是驾驶员可以成为帮手和viseversa。

*

SampleData:

I have a tblWork that has a dozen fields in it.
It tracks hours worked for 2 employees at a time.
- fldDriverID
- fldDriverHours
- fldHelperID
- fldHelperHours

It also has a date field (fldDate) and a key to the ticket the work was performed on (fldTicketID).

So I assign the driver and the hours worked (1,15h) same for helper (1,13h)

What i want to do is do a payroll select that will get me the DriverHours and HelperHours for each employee. that is easy to do but the hard part is that the driver can be the helper and viseversa.
*
SampleData:

展开 | 选择 | Wrap | 行号

推荐答案

Wlecome to TSDN!


到目前为止你做了什么?
Wlecome to TSDN!

What you have made so far?



Wlecome to TSDN!


到目前为止你做了什么?
Wlecome to TSDN!

What you have made so far?



我用我迄今为止编辑的原始帖子编辑了。


目前我正在为每位员工反复显示选择(需要时间,特别是一旦他们为30多名员工做了),我想把它作为一个选择结果。


谢谢,

Jordon

I edited my original post with what i have so far.

Currently I am doing the select shown over and over again for each employee (takes time, especially once they do it for 30+ employees), I would like to get it as one select with the results.

Thanks,
Jordon



我尝试了什么,得到了接近
What I tried, got close



你的查询给出了所需的结果,对吗?


要获得多个结果,请更换以下条件与JOIN到employee表和WHERE子句提供员工ID。

Your query giving the required results, right?

To get multiple results, replace the following condition with a JOIN to employee table and in WHERE clause provide the employee ids.

展开 | 选择 | Wrap | 行号


这篇关于使用2个关键字段在两个字段上选择Sum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆