在出生日期相关的QueryMonth在升序中 [英] In Date of Birth Month Related QueryMonth to be in Ascending Order
问题描述
我在数据库中有一列是DOB(出生日期)
在该数据库中,DOB的所有员工详细信息都插入了记录。
DOB(出生日期格式为mm / dd / yyyy)
示例如下;
DOB(IN数据库DOB有这样的名字)格式为mm / dd / yyyy)
DOB(在数据库中)
M / D / YYYY
9/16/1945
4/10/1952
6/30/1978
4/19/1981
4/5/1944
4/11/1948
3/12/1977
5/29/1989
7/23/1944
8/11/1974
9/24/1973
10/26/1978
11/2/1990
12/17/1995
1/30/1997
2/24/1990
如何编写查询。
i have one column in database that is DOB(Date of Birth)
in that database all employee details of DOB has inserted records are there.
DOB(Date of birth format as mm/dd/yyyy)
Example as follows;
DOB( IN Database DOB has name like that) Format as mm/dd/yyyy)
DOB(In Data Base)
M/D/YYYY
9/16/1945
4/10/1952
6/30/1978
4/19/1981
4/5/1944
4/11/1948
3/12/1977
5/29/1989
7/23/1944
8/11/1974
9/24/1973
10/26/1978
11/2/1990
12/17/1995
1/30/1997
2/24/1990
for that how to write the query.
select Name, CONVERT(varchar(11), DOB, 106) AS Date_of_birth,Mobileno as Mobile_Number, CONVERT(varchar(11), Weddingday, 106) AS Wedding_Day,EMail as E_Mail from BirthDayWish where Active = 'A' ORDER BY Name;
来自上面的查询如何写月(1到12)以升序显示。
i希望月份(1到12)按升序排列。
我想要输出如下。从上面的查询得到如下输出。
M / D / YYYY
1/30/1997
2/24/1990
3/12/1977
4/19/1981
4/5/1944
4/11 / 1948年
4/10/1952
5/29/1989
6/30/1978
7 / 23/1944
8/11/1974
9/16/1945
9/24/1973
10/26/1978
11/2/1990
12/17/1995
from the above query how to write the Month(1 to 12) to be Displayed in ascending order.
i want the month(1 to 12) to be arranged in ascending order.
I want the output as follows.from the above query how to get the below output.
M/D/YYYY
1/30/1997
2/24/1990
3/12/1977
4/19/1981
4/5/1944
4/11/1948
4/10/1952
5/29/1989
6/30/1978
7/23/1944
8/11/1974
9/16/1945
9/24/1973
10/26/1978
11/2/1990
12/17/1995
推荐答案
使用时sql server 2005或更新版
When using sql server 2005 or newer
Order by Name, Month(DOB)
这篇关于在出生日期相关的QueryMonth在升序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!