sql - Convert result within statement -


Assume that I have the following simple query

  select the top 1 name for months < / Code> 

which gives name = "march" is it possible to change this result? Instead of "march" let me name = "3" what SQL is able to do such things? I am using an MSSQL database.

[Update] Corrected the query. When writing this simple example, I mixed it with MySQL [/ Update]

You want to map a certain set of input values ​​against a certain set of output values, when is the case your friend:

  select name name then 'Jan' was then 1 when 'February' then 2 when 'march' then 3 / * ... * / END months as number of  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -