select top 10000 b.Code,b.Name,b.EffDateShortControl 标识,b.EffDateControlStart 开始时间,
b.EffDateControlEnd 结束时间,b.EffDateShortDays 缩短日期,
c.InputDate 入库日期,a.EffDate 入库原始有效日期,
CASE isnull(EffDateShortControl,0)
when 0
then a.EffDate
when 1
then
case when c.InputDate>=b.EffDateControlStart and c.InputDate<=b.EffDateControlEnd
then a.EffDate-b.EffDateShortDays
else case when c.InputDate>b.EffDateControlEnd or c.InputDate<b.EffDateControlStart
then a.EffDate
end
end
END AS 缩短日期--如果不启用质检就直接可用
from W_doc_receiving_master c inner join W_doc_receiving_detail a
on c.ID = a.MasterId
left join W_inf_product b on a.ProdId=b.Id
SQLServer Case when 嵌套
推荐阅读
- 学习python第五天
- 解决Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)错误//解决 413 Request Entity Too Large
- 前端获取Ajax请求获取数据,无法赋值给全局变量
- PHP 二维数组去重(保留指定键值的同时去除重复的项)
- ps -ef|grep详解
- php将两个数组相同的key合并到一个数组
- 【PHP】Maximum execution time of 30 seconds exceeded解决方案
- postman参数为Json数据结构
- Redis存储总用String?你大概错过了更优的使用方法
- 修改layui的后台模板的左侧导航栏可以伸缩