Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
Strategies
»
Select clause SQL Quary
Select clause SQL Quary
Rate Topic
Display Mode
Topic Options
Author
Message
saurabhvashistha
saurabhvashistha
Posted Friday, July 03, 2009 3:00 AM
Forum 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
Dave Ballantyne
Dave Ballantyne
Posted Friday, July 03, 2009 3:03 AM
SSCommitted
Group: General Forum Members
Last Login: Friday, May 10, 2013 4:07 PM
Points: 1,943,
Visits: 8,227
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
saurabhvashistha
saurabhvashistha
Posted Friday, July 03, 2009 3:07 AM
Forum 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
Dave Ballantyne
Dave Ballantyne
Posted Friday, July 03, 2009 3:13 AM
SSCommitted
Group: General Forum Members
Last Login: Friday, May 10, 2013 4:07 PM
Points: 1,943,
Visits: 8,227
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
saurabhvashistha
saurabhvashistha
Posted Friday, July 03, 2009 3:20 AM
Forum 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
Ian Scarlett
Ian Scarlett
Posted Friday, July 03, 2009 3:30 AM
Ten Centuries
Group: General Forum Members
Last Login: Today @ 2:12 AM
Points: 1,322,
Visits: 4,400
... or if it's homework, you need to do a bit more studying.
Post #746888
Dave Ballantyne
Dave Ballantyne
Posted Friday, July 03, 2009 3:34 AM
SSCommitted
Group: General Forum Members
Last Login: Friday, May 10, 2013 4:07 PM
Points: 1,943,
Visits: 8,227
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
saurabhvashistha
saurabhvashistha
Posted Friday, July 03, 2009 3:46 AM
Forum 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 »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.