Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Select clause SQL Quary Expand / Collapse
Author
Message
Posted Friday, July 3, 2009 3:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 20, 2010 10:54 PM
Points: 4, Visits: 15
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

Post #746875
Posted Friday, July 3, 2009 3:03 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 4:50 AM
Points: 1,949, Visits: 8,315
By using the case statement

select ....,case when money >=10000 then 'A' else 'B' end as Grade
from ....




Clear Sky SQL
My Blog
Kent user group
Post #746877
Posted Friday, July 3, 2009 3:07 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 20, 2010 10:54 PM
Points: 4, Visits: 15
Can you Please provide a query for getting that result...
Post #746878
Posted Friday, July 3, 2009 3:13 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 4:50 AM
Points: 1,949, Visits: 8,315
I dont wish to be rude , but if that is causing you troubles you really need to go on a course.



Clear Sky SQL
My Blog
Kent user group
Post #746880
Posted Friday, July 3, 2009 3:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 20, 2010 10:54 PM
Points: 4, Visits: 15
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...
Post #746883
Posted Friday, July 3, 2009 3:30 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, July 30, 2014 7:22 AM
Points: 1,327, Visits: 4,506
... or if it's homework, you need to do a bit more studying.


Post #746888
Posted Friday, July 3, 2009 3:34 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 4:50 AM
Points: 1,949, Visits: 8,315
Take a look at Books Online

http://msdn.microsoft.com/en-us/library/ms130214.aspx




Clear Sky SQL
My Blog
Kent user group
Post #746892
Posted Friday, July 3, 2009 3:46 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 20, 2010 10:54 PM
Points: 4, Visits: 15
Aha!!!!! I got Now i am able to create such queries thanks for help.....
Post #746898
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse