如何解决SQL Server - 计算接下来的五个工作日
我有一个要求,我必须从今天开始计算接下来的 5 个工作日,以计算预计的开放销售额。
我必须在我的 sql 查询中应用它作为过滤器。我在下面附上我的查询,其中包括周末。如果有人建议我找出除周末(周六和周日)之外的接下来 5 个工作日的解决方案,那将会很有帮助
select
s.salesid,l.itemid,l.SHIPPINGDATEREQUESTED as 'Ship Date',Case when not l.salesqty = 0 then (l.LINEAMOUNT/l.SALESQTY) * l.REMAINSALESPHYSICAL else 0 end as 'Projected Open Sales',from dbo.salestable s
inner join dbo.salesline l
on s.salesid = l.salesid and s.dataareaid = l.dataareaid and s.partition = l.partition
inner join dbo.inventtable i on l.itemid = i.itemid and l.DATAAREAID = i.DATAAREAID and l.partition = i.PARTITION
inner join dbo.ECORESTRACKINGDIMENSIONGROUPITEM ti on l.itemid = ti.itemid and l.DATAAREAID = ti.ITEMDATAAREAID and l.PARTITION = ti.PARTITION
inner join dbo.ECORESTRACKINGDIMENSIONGROUP g on ti.TRACKINGDIMENSIONGROUP = g.recid
where
s.SHIPPINGDATEREQUESTED > = getdate() and
s.SHIPPINGDATEREQUESTED <= getdate() + 5 and
and s.salestype in (0,3)
and l.salesstatus in (0,1)
and not l.salesqty = 0
order by s.SHIPPINGDATEREQUESTED asc
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。