首页 > 解决方案 > 不为空时从其他表更新表日期字段

问题描述

我想从同一个表中的一些记录(条目类型 = 1)更新表中为条目类型 = 4 提交的日期,但是得到一个无法在字段中插入空数据的错误。

UPDATE [Item Ledger Entry] 
  SET [Last Invoice Date] = (Select  MAX([Posting Date])
                               from  [Item Ledger Entry] ILE2 
                               where ILE2.[Item No_] = ILE1.[Item No_] AND
                                     ILE2.[Posting Date] <= ILE1.[Posting Date] AND
                                     ILE2.[Entry Type] = 1 AND 
                                     ILE2.[Posting Date] is not null
                            )
 FROM  [Item Ledger Entry] ILE1
 where ILE1.[Entry Type] = 4

标签: sql-scripts

解决方案


推荐阅读