sql - 从表列中的 SQL Server 日期值获取月份名称
问题描述
我想创建一个统计查询(显示每月的记录数)。
问题是我希望月份以字母显示,例如一月、二月、三月等,而不是像 1、2 或 3。我没有使用month(getdate()
.
我不知道如何进行转换。这是我的 SQL Server 查询:
select count(*) [Total], month(date) [Mois]
from user
where year(date) >= 2018
group by month(date)
order by month(date) desc
解决方案
你应该尝试这样的事情
select convert(char(3), [date], 0)
select datename(month, [date])
推荐阅读
- java - 当有多个注入组件候选注入时,spring如何进行依赖注入
- azure-machine-learning-studio - 使用 Azure 机器学习设计器从 DataStore 创建 DataSet 时登录失败
- javascript - 在从服务器获取的选择(选项)中追加数据
- flutter - 颤振哨兵未定义功能'runZonedGuarded'
- angular - 打字稿:参数类型字符串 [] 不能分配给参数类型任何
- io - 操作系统如何处理输入操作?
- c# - 根据复选框状态添加/删除用户控件。如果已检查用户控件添加正确但无法删除
- google-bigquery - 关于引用列位置和列数的 CSV 表的错误
- php - 显示来自存储路径 laravel 的文件
- python - “AttributeError:‘模块’对象没有属性‘CUIAutomation’”