July 3, 2009 at 3:00 am
Lets Create a table
Create Table test(Name varchar(50), SalaryAmount money)
insert into test(Name, SalaryAmount) values(A, 10000)
insert into test(Name, SalaryAmount) values(b, 11000)
insert into test(Name, SalaryAmount) values(d, 110000)
insert into test(Name, SalaryAmount) values(f, 10000)
insert into test(Name, SalaryAmount) values(g, 9800)
insert into test(Name, SalaryAmount) values(h, 10000)
insert into test(Name, SalaryAmount) values(k, 8000)
insert into test(Name, SalaryAmount) values(l, 10000)
insert into test(Name, SalaryAmount) values(n, 15000)
Now i Have to write a query which give me result like if Salary is greater then or equal to 10000 grade A else b like
Result should be
Name Grade
A A
b A
d A
f A
g b
h A
k b
l A
n b
How do I accomplish this can anyone suggest
July 3, 2009 at 3:03 am
By using the case statement
select ....,case when money >=10000 then 'A' else 'B' end as Grade
from ....
July 3, 2009 at 3:07 am
Can you Please provide a query for getting that result...
July 3, 2009 at 3:13 am
I dont wish to be rude , but if that is causing you troubles you really need to go on a course.
July 3, 2009 at 3:20 am
Yes Sir i understand that, but i am in urgent need for the query as i am facing issues in developing that, i am new to SQL and i am in learning phase. So Please do help if u can...
July 3, 2009 at 3:30 am
... or if it's homework, you need to do a bit more studying.:-D
July 3, 2009 at 3:34 am
Take a look at Books Online
July 3, 2009 at 3:46 am
Aha!!!!! I got Now i am able to create such queries 🙂 thanks for help.....
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply