Update column with autonumber

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 19:09:46

问题


I need to figure out when each person will complete a task based on a work calendar that won't include sequential dates. I know the data in two tables T1

Name DaysRemaining  Complete
Joe      3
Mary     2

and T2

Date        Count
6/1/2018
6/8/2018
6/10/2018
6/15/2018

Now if Joe has 3 days remaining I would like to count 3 records forward from today in T2 and return the date to the Complete column. If today is 6/1/2018 I would want the Update query to return 6/10/2018 to the Complete column for Joe.

My thought is that I could daily update T2.count with a query that began today and would then autoincrement. Following that I could join the T1 and T2 on DaysRemaining and Count. I can do that but haven't found a working solution for updating t2.count with autoincrement. Any better ideas? I am using a linked sharepoint table so creating a new field each time would not be an option.


回答1:


I think this will work:

select t1.*, t2.date
from t1, t2  -- ms access doesn't support cross join
where t1.daysremaining = (select count(*)
                          from t2 as tt2
                          where tt2.date <= t2.date and tt2.date > now()
                         );

This is an expensive query and one that is easier to express and more efficient in almost any other database.



来源:https://stackoverflow.com/questions/50237731/update-column-with-autonumber

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!