使用动态字段名称查询 [英] Query with dynamic field names
问题描述
您好,
我正在尝试构建一个具有独特问题的查询。 我们有多个部门。 每条记录都分配了一个当前位置,并根据该位置属于某个部门(某些部门有多个位置)。 每个部门
都有一定的天数来完成记录中的任务。 我正在尝试计算他们'ProcessTime'剩余的天数,直到他们迟到。
I'm trying to build a query with a unique problem. We have multiple departments. Each record is assigned a current location and based on that location it belongs to a certain department (some departments have multiple locations). Each department has a certain number of days to complete a task on the record. I'm trying to calculate the number of days left on their 'ProcessTime' until they are late.
问题是我有一个DeptStartDate字段,我需要用来做每个部门计算。 我不想创建一些超级嵌套的if语句来返回相应的日期字段。
The issue is i have a DeptStartDate field for each department that I need to use to do the calculation. I don't want to create some super nested if statement to return the respective date field.
以下是适用的字段名: ContainerID(PK),HBStartDate,CLStartDate,CRStartDate,PKStartDate,SHStartDate,DeptCode(HB,CL,CR,PK,SH),ProcessTime。
Here's the fieldnames that are applicable: ContainerID (PK), HBStartDate, CLStartDate, CRStartDate, PKStartDate, SHStartDate, DeptCode (HB, CL, CR, PK, SH), ProcessTime.
所以用外行的话来说...... 今天 - xxStartDate + ProcessTime
So in layman's terms... Today - xxStartDate + ProcessTime
如何根据DeptCode传递xxStartDate字段?
How do I pass the xxStartDate field based on DeptCode?
任何帮助都会很棒......
Any help would be great...
恩斯特。
推荐答案
你需要的是一个相关的带有ContainerID(FK),DeptCode和StartDate字段的'child'表。
What you need is a related 'child' table with ContainerID (FK), DeptCode, and StartDate fields.
将关系创建为一对多。
Create the relationship as one-to-many.
这篇关于使用动态字段名称查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!