在同一查询中计算YTD,上一个YTD [英] Calculate YTD, Previous YTD in the same query

查看:123
本文介绍了在同一查询中计算YTD,上一个YTD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述






如何计算在同一查询中计算YTD和之前的YTD?

推荐答案

嗨jaweher ,

Hi jaweher,

希望下面的人会帮助你。

Hope the below one will help you.

Select (Case when TestDate between '01/01/2019' and '20/03/2019' then Sum(TestValues) else 0 end) 'Current',
(Case When TestDate between '01/01/2018' and '20/03/2019' then Sum(TestValues) else 0 end) 'Previous'
From TestTable




注意:建议易于理解和实施的众多方法之一。



如果它解决了您的问题,请将此标记为答案。 

如果它有助于解决您的问题,请将此投票视为有用。 



在预付款中感谢,

Arulmouzhi


Note: Suggested one of the many ways that is easy to understand and implement.

Please mark this as answer if it solved your issue. 
Please vote this as helpful if it helps to solve your issue. 

Thanks in Advance,
Arulmouzhi


这篇关于在同一查询中计算YTD,上一个YTD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆