通过jan,feb给出的订单更正此查询 [英] correct this query for order by jan,feb given out put

查看:53
本文介绍了通过jan,feb给出的订单更正此查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

out put可以给出

======================

月份

11月

12月

Jan







鉴于这种格式出来

======================



Jan

2月

..

订购







使用此查询

================

  SELECT   DISTINCT  DATENAME(月,STR(年)( StudentAttendanceDate), 4 )+ REPLACE(STR(CurrentMonth, 2 ),' ''  0 ')+ '  01' as 月份
来自 tbl_StudentAttendanceMaster
订单

解决方案

  SELECT   distinct  DATENAME(month,StudentAttendanceDate) AS  ' 月份名称 来自 tbl_StudentAttendanceMaster 
订单 [月份名称]


如果您只有月份名称,可以尝试下面



 创建  #table(MonthNames  varchar  12 ))
insert #table 选择 ' Jan'
insert #table select < span class =code-string>' Mar'
insert #表选择 ' 2月'


选择 MonthNames
来自 #table
订单 转换日期,MonthNames + ' 01 1900'


out put can given
======================
Month
Nov
Dec
Jan



Given this format out put
======================
Month
Jan
Feb
..
Order by



used this query
================

SELECT DISTINCT DATENAME(month, STR(YEAR(StudentAttendanceDate), 4) + REPLACE(STR(CurrentMonth, 2), ' ', '0') + '01')as Months
from tbl_StudentAttendanceMaster
order by Months

解决方案

SELECT distinct  DATENAME(month, StudentAttendanceDate) AS 'Month Name'from tbl_StudentAttendanceMaster
order by [Month Name]


If you have only month names with you,you can try below

Create  table #table(MonthNames varchar(12))
insert #table select 'Jan'
insert #table select 'Mar'
insert #table select 'Feb'


select MonthNames
from #table
Order by convert(Date,MonthNames+' 01 1900')


这篇关于通过jan,feb给出的订单更正此查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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