sql 공부하는 초보입니다.
혹시 mssql에 이런식으로 년도를 핵사표시로 할 수 있는 방법이 있을까요?
EX)
2010년 - 0A
2011년 - 0B
2012년 - 0C
2013년 - 0D
2014년 - 0E
2015년 - 0F
2016년 - 10
2017년 - 11
2018년 - 12
2019년 - 13
2020년 - 14
2021년 - 15
2022년 - 16
2023년 - 17
2024년 - 18
2025년 - 19
2026년 - 1A
2027년 - 1B
....
이런식으로요 혹시 방법이 있다면 좀 알려주시면 감사하겠습니다!!ㅎㅎ
Comment 1
-
건우아빠
2017.04.10 12:00
with resas(select '2010' yy unionselect '2011' yy unionselect '2012' yy unionselect '2013' yy unionselect '2014' yy unionselect '2015' yy unionselect '2016' yy unionselect '2017' yy unionselect '2018' yy unionselect '2019' yy unionselect '2010' yy unionselect '2011' yy unionselect '2012' yy unionselect '2013' yy unionselect '2014' yy unionselect '2015' yy unionselect '2016' yy unionselect '2017' yy unionselect '2018' yy unionselect '2019' yy unionselect '2020' yy unionselect '2021' yy unionselect '2022' yy unionselect '2023' yy unionselect '2024' yy unionselect '2025' yy unionselect '2026' yy unionselect '2027' yy )select * , right(upper(master.dbo.fn_varbintohexstr(CAST( CAST( RIGHT(yy,2) as integer) as varbinary ))) ,2)from res