Friday, February 19, 2016

Fetching last 6 months data in Maximo using SQL Server with output in a specific language

Below is one of the best ways to find number of tickets created in last 6 months in Maximo using SQL Server database in a specific language.
here i am using Portugese as lanuage in which my output should be

Query is self explanatory


select CASE month
WHEN  'January' THEN 'Janeiro de'
WHEN  'February' THEN 'Fevereiro'
WHEN  'March' THEN 'Março de'
WHEN  'April' THEN 'Abril'
WHEN  'May' THEN 'Maio'
WHEN  'June' THEN 'Junho de'
WHEN  'July' THEN 'Julho'
WHEN  'August' THEN 'Agosto'
WHEN  'September' THEN 'Setembro de'
WHEN  'October' THEN 'Outubro'
WHEN  'November' THEN 'Novembro de'
  ELSE 'Dezembro de'
END month,countoftickets from ( SELECT DATENAME(MONTH,DATEADD(month, -5, GETDATE())) month,COUNT(*) AS countoftickets , 1 as fs FROM ticket WHERE MONTH(creationdate) = MONTH(DATEADD(month, -5, GETDATE())) union  SELECT DATENAME(MONTH,DATEADD(month, -4, GETDATE())) month,COUNT(*) AS countoftickets , 2 as fs FROM ticket WHERE MONTH(creationdate) = MONTH(DATEADD(month, -4, GETDATE())) union  SELECT DATENAME(MONTH,DATEADD(month, -3, GETDATE())) month,COUNT(*) AS countoftickets , 3 as fs  FROM ticket WHERE MONTH(creationdate) = MONTH(DATEADD(month, -3, GETDATE())) union  SELECT DATENAME(MONTH,DATEADD(month, -2, GETDATE())) month,COUNT(*) AS countoftickets , 4 as fs  FROM ticket WHERE MONTH(creationdate) = MONTH(DATEADD(month, -2, GETDATE())) union  SELECT DATENAME(MONTH,DATEADD(month, -1, GETDATE())) month,COUNT(*) AS countoftickets , 5 as fs  FROM ticket WHERE MONTH(creationdate) = MONTH(DATEADD(month, -1, GETDATE())) union  SELECT DATENAME(MONTH,DATEADD(month, 0, GETDATE())) month,COUNT(*) AS countoftickets , 6 as fs  FROM ticket WHERE MONTH(creationdate) = MONTH(DATEADD(month, 0, GETDATE()))  ) a1  order by fs

output:

month countoftickets
Setembro de 0
Outubro 0
Novembro de 0
Dezembro de 22
Janeiro de 57
Fevereiro 34






----------------------------------------------------------------------------
All the messagesbelow are just forwarded messages if some one feels hurt about it please add your comments we will remove the post.Host/author is not responsible for these posts.

No comments:

Post a Comment