Link to home
Start Free TrialLog in
Avatar of mousemat24
mousemat24

asked on

Placing calendar month names instead of int

Hi There

I have this SQL

and what I want to do is rather then displaying a int for the month, I like to have the acauly name of the month i.e.

where HTC_Month = 1, put January ... where HTC_Month = 10 put October, all the way to December

And also a sort, where it will sort by Year then month, so the latest year (HTC_Year) will be at the top and then the latest month (HTC_Month) and the top as well.

Hope this makes sense?

Thankyou so much
SELECT     dbo.HTC_HitCounter.HTC_Year, dbo.HTC_HitCounter.HTC_Month, dbo.HTC_HitCounter.HTC_Counter, 
                      dbo.MNU_Menu.MNU_DisplayName, dbo.MNU_Menu.MNU_URL, dbo.MNU_Menu.MNU_Description, dbo.MNU_Menu.MNU_Hidden, 
                      dbo.HTC_HitCounter.HTC_MNU_ID
FROM         dbo.HTC_HitCounter INNER JOIN
                      dbo.MNU_Menu ON dbo.HTC_HitCounter.HTC_MNU_ID = dbo.MNU_Menu.MNU_ID

Open in new window

Avatar of princeatapi
princeatapi
Flag of India image

Use CASE construct while inserting
eg;

INSERT INTO MTABLE
(col1
,col2)
SELECT col1
,(CASE WHEN UPPER(col2) LIKE '%STUFF%' THEN
(SELECT COL1
FROM TAB3
WHERE UPPER(NAME) = 'STUFF')
ELSE
(SELECT COL1
FROM TAB3
WHERE UPPER(NAME) = 'MORESTUFF')
END) STUFF_ID
FROM [Email Address Removed] WHERE client_id = 1;
ASKER CERTIFIED SOLUTION
Avatar of Dimitris
Dimitris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mousemat24
mousemat24

ASKER

Thankyou so much for helping me guys.