如何动态更改日期字段? [英] How to dynamically change a date field?
问题描述
我正试图找到一种动态更改最早日期字段日期的方法,所以如果
TotalShipped = TotalOrdered 那么我想采取最早的日期这两个字段彼此不相等。这是我正在尝试做的一个例子。
I'm trying to find a way to dynamically change the dates of the Earliest Date field so if the TotalShipped = TotalOrdered then I want to take the earliest date where the two fields don't equal each other. This is an example of what I'm trying to do.
+ ---- + ---------- + - --- + ----------- + ---------- + -----------
|   ;  | NAME     | TS  | TO        |日期     |最早的日期 |
+ ---- + ---------- + ----- + ----------- + ------ ---- + -----------
| 1 | 039069   |  1  | 1         |   3-19   | 3-20      |
| 2 | 039069   |  1  | 1         |  3-19    | 3-20      |
| 3 | 039069   |  1  | 0         |  3-20    | 3-20      |
| 4 | 039069   |  1  | 0         |  3-21    | 3-20      |
----------------------------------------- ----------------
SELECT
sorels.fsono,
sorels.finumber,
sorels.frelease,
fshipbook+fshipbuy+fshipmake as totalshipped,
fjoqty + fbook + fbqty as totalordered,
sorels.fduedate
FROM m2mdata35.dbo.sorels
INNER JOIN somast on sorels.fsono=somast.fsono
INNER JOIN soitem on sorels.fsono=soitem.fsono AND sorels.finumber=soitem.finumber
LEFT JOIN inmastx on soitem.fpartno=inmastx.fpartno and soitem.fpartrev=inmastx.frev
LEFT JOIN jomast on sorels.fstatus=jomast.fjobno
LEFT JOIN slcdpmx on somast.fcustno=slcdpmx.fcustno
LEFT JOIN syphon ON somast.fcontact=syphon.fcontact AND somast.fcustno=syphon.fcsourceid
WHERE LEFT(somast.fstatus,1)<>'C' and fsocoord<>'IFP' and fsocoord<>'711'
and somast.fsono='039069'
Order By sorels.fsono, sorels.fduedate, sorels.finumber, sorels.frelease
推荐答案
不清楚这里的含义,请发布更多详细信息,例如带数据的示例表作为DML语句和预期的结果。
Not clear what you mean here, please post more details like an example table with data as DML statement and the expected result.
这篇关于如何动态更改日期字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!