如何获得到目前为止的任何月份日期 [英] how to get whatever months present till today date

查看:99
本文介绍了如何获得到目前为止的任何月份日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WITH    CTE
          AS ( SELECT   GETDATE() Today
               UNION ALL
               SELECT   DATEADD(mm, -1, today)
               FROM     CTE
               WHERE    MONTH(Today) > 1
             )
    SELECT  DATENAME(mm, today)
    FROM    CTE
    ORDER BY MONTH(today)







此查询执行并显示直到今天的日期以行为单位

但我想要列明智请任何人都可以帮助我




this query execute and it show month till today date in row wise
but i want column wise please can any one help me

推荐答案

你需要 PIVOT 函数...见这里示例 [ ^ ]
You need the PIVOT function ... see here for an example[^]


这篇关于如何获得到目前为止的任何月份日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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