mercredi 2 décembre 2015

get last 3 month on year in sql server

I want to get last 3 months name from current month. For example current month is December. So, I want get like this October, November and December.

this is my query

SELECT CONVERT(CHAR, DATENAME(MONTH, IssueDate)) AS MonthName, ItemId
FROM dbo.Issue AS Issue
GROUP BY CONVERT(CHAR, DATENAME(MONTH, IssueDate)), ItemId
HAVING (ItemId = 427)

Now show this

But, my need is - required this

N.B. When December month close and January month open then October auto excluded as like (November, December and January)

Aucun commentaire:

Enregistrer un commentaire