Select clause SQL Quary

  • 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

  • By using the case statement

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

    from ....



    Clear Sky SQL
    My Blog[/url]

  • Can you Please provide a query for getting that result...

  • 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[/url]

  • 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...

  • ... or if it's homework, you need to do a bit more studying.:-D

  • Take a look at Books Online

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



    Clear Sky SQL
    My Blog[/url]

  • 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