Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

I need to select a string which is not from my db. i need something like select name, age, gender, level = (if points <= 499 'newbie', if points >= 500 'expert') how to this in sql? is it possible?

Thanks!!
Posted

1 solution

So you mean level is not a field?

On this point, you need to use a SELECT CASE statement to meet your desired output. Here, try this:

SQL
SELECT     name
          ,age
          ,gender
          ,'level' = CASE
                         WHEN points <= 499 THEN 'newbie'
                         WHEN points >= 500 THEN 'expert'
                         ELSE 'unknown'
                     END
FROM      [TableName]


Regards,
Eduard
 
Share this answer
 
Comments
Aja wakim 13-Dec-11 9:39am    
this works! thanks for your usual support!
[no name] 13-Dec-11 20:32pm    
thank u for deducting 16 consecutive pts whoever u are! hater! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900