Valid.sql
资源名称:SQLVC.rar [点击查看]
上传用户:biney012
上传日期:2022-05-09
资源大小:4592k
文件大小:1k
源码类别:
数据库系统
开发平台:
Visual C++
- USE Stock
- GO
- CREATE VIEW dbo.Valid
- AS
- SELECT dbo.ProInStore.SpId AS 库存记录编号, dbo.Product.Pname AS 产品名称,
- dbo.ProInStore.Pprice AS 产品价格, dbo.ProInStore.Pnum AS 产品数量,
- dbo.ProInStore.MakeDate AS 生产日期, dbo.Storehouse.Sname AS 仓库名称,
- ROUND(DATEDIFF(day, DATEADD(day, dbo.Product.Valid, dbo.ProInStore.MakeDate),
- GETDATE()), 0) AS 距离失效期的天数
- FROM dbo.ProInStore INNER JOIN
- dbo.Product ON dbo.ProInStore.Pid = dbo.Product.Pid AND DATEDIFF(day,
- GETDATE(), dbo.ProInStore.MakeDate)
- >= dbo.Product.Valid - dbo.Product.AlarmDays INNER JOIN
- dbo.Storehouse ON dbo.ProInStore.Sid = dbo.Storehouse.Sid
- GO