Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Merge date columns, display month as MMM and sort date by DESC

Avatar of baberamin
baberaminFlag for Canada asked on
Microsoft SQL ServerSQL
7 Comments1 Solution118 ViewsLast Modified:

I have a query in SQL Server 2014

select month((CDate)) as CreateMonth, year((CDate)) as CreateYear, count(*) "No of Users"

from kf, dt

where kf.type=0 and kf.ID=dt.ID

group by month(CDate), year(CDate)
order by year(CDate) desc, month(CDate) desc

It display results as below:

CreateMonth      CreateYear      No of Users
-------------------        ----------------     -----------------
10                              2018              7
9                              2018             9
8                              2018             6
7                              2018             3

Now I want to have results as below:

CreateMonthYear      No of Users
--------------------------     -----------------
Oct 2018                   6
Sep 2018                  16
Aug 2018                  3
July 2018                  20


1. Converting Month from numeric to three character Alphabets
2. Merging year together with month
3. Date column should be sorted DESC