本文介绍了TSQL - 小于或大于日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我想生成一个查询,显示如果 startdate 小于 4 个月,则给出 5%,如果它大于 4 个月给出 10%.
I would like to produce a query that shows if startdate is less than 4 months old give 5% if its older than 4 months give 10%.
我正在使用 SQLFiddle,但没有得到正确的输出.目前它在所有列上给我 5% 或者如果我替换
I am using SQLFiddle and I not getting the right output. At the moment it’s giving me 5% on all the columns or if I replace
到
查询成功但不显示数据.
It will query successfully but does not show data.
这是我做的代码...
如果有人可以帮助我,请提前致谢.
Thanks in advance if anyone can help me.
推荐答案
在update
中使用case
语句根据date
分配折扣
Use case
statement in update
to allocate discount based on date
像这样尝试update
这篇关于TSQL - 小于或大于日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!