Basic SQL Programming Question - Joining 3 tables then sorting

  • bump for help.

  • could you supply some the definition of your table and some sample data with the expect output.

    It's pretty hard to write a query for a desired output if you dont' know what data you working with.

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • You'll also need a column in your query for the table or something else to group by.

    For your results, not sure what the values mean.

  • Chris hit it perfectly.

  • try this:

    SELECT

    Category,

    COUNT(*)

    FROM

    (SELECT

    CASE WHEN salary between 0 and 10000 then 'range = 20000 and salary = 30000 and salary = 40000 and salary = 50000 and salary = 60000 and salary = 70000 and salary = 80000 and salary = 90000 and salary = 100000 and salary < 110000 then 'range $100k-$110k'

    ELSE 'OTHER'

    END as Category

    FROM employee) n

    GROUP BY Category

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • perfection!!!

    Thanks

  • Dabears2k, Also go through the first link in Christopher's signature. This will help you to get correct answer to the point in future :-). You posted desired output much later than it should have been. i concentrated more on the syntax than the output:hehe:.



    Pradeep Singh

  • needed to do a select within a select with a join

  • making headway

  • finished

Viewing 10 posts - 16 through 24 (of 24 total)

You must be logged in to reply to this topic. Login to reply