VYX Level: Professor Registered: 16-12-2005 Posts: 70
SQL SERVER 2000 with Conditional select Statement
How can i make a sql select statement that will do like this that if the age is less than 18 it will create a new field like status which value is 'notallowed' and if age is greater or equal to 18 the field status created will put a value 'allowed'
tablename:tblinfo
field:name,age
name age status
-----------------------------------
a 15 allowed
b 18 notallowed
c 18 allowed
select name,age (if age>=18):status='ALLOWED' ELSE STATUS='NOTALLOWED' FROM TBLinfo
Anybody have any idea on how to do like this to integrate with vb6 code..
i believe that sql server 2000 could do the conditional with select statement ?
thank you very much in advance guys..
I really appreciate all your post here
28-07-2007 at 02:38 AM
|
stickleprojects Level: Moderator Registered: 09-09-2002 Posts: 891
Re: SQL SERVER 2000 with Conditional select Statement
Hi,
select name,age, (CASE WHEN age>=18 THEN 'ALLOWED' ELSE 'NOTALLOWED' END) as Status FROM TBLinfo
Hope this helps,
Kieron
____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)
07-08-2007 at 02:42 PM
|
VYX Level: Professor Registered: 16-12-2005 Posts: 70
Re: SQL SERVER 2000 with Conditional select Statement
Thank you very much kieron..
wow.. so great...Im so glad for your immediate help. my problem was solved. it did what i suppose to be...thanks a lot !!!
Now im trying to convert my sql server 2000 into sql server 2005. I have an installer standard edition and installed to my pc but it seems not just like a sql server 2000 that your going to enterprise manager and create a database and tables there..
Do you have any links that guide me through? or a downloadable ebooks that could help me..