Simple Oracle Query

Discussion in 'QnA (read only)' started by DukeNukem, Sep 26, 2006.

Thread Status:
Not open for further replies.
  1. DukeNukem

    DukeNukem Come get Some

    Joined:
    Aug 28, 2005
    Messages:
    417
    Likes Received:
    2
    Trophy Points:
    0
    Location:
    Home Sweet Home
    Hye There

    Can any of you help me with this

    Create query that displays the employees last names and indicates the amounts of their annual salaries with asterisks. Each asterisk signifies a thousand dollars. Sort the data in descending order of salary. Label the column EMPLOYEES_AND_THEIR_SALARIES.
     
  2. wizrulz

    wizrulz GUNNING DOWN TEAMS

    Joined:
    Mar 5, 2005
    Messages:
    1,724
    Likes Received:
    21
    Trophy Points:
    0
    Location:
    MUMBAI
    select rpad(last_name,8 )||' '||RPAD(' ',salary/1000+1,'*') EMPLOYEES_AND_THEIR_SALARIES

    From employee
    order by salary DESC;


    I THINK U GOT UR ANS ;)
    __________
    Did u genuinely had problem with this...as i feel u knew the ans and just wanted to check out members oracle knowledge.....
     
    Last edited: Sep 27, 2006
  3. vikasg03

    vikasg03 New Member

    Joined:
    Oct 8, 2005
    Messages:
    184
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Dubai
    you can use floor also like this

    rpad('*',floor(salary/1000),'*')
     
  4. wizrulz

    wizrulz GUNNING DOWN TEAMS

    Joined:
    Mar 5, 2005
    Messages:
    1,724
    Likes Received:
    21
    Trophy Points:
    0
    Location:
    MUMBAI
    yeah thats true...but to make it easy to understand if he really had problem......i used it other way around.... ;)
     
  5. binayak_oracle

    binayak_oracle New Member

    Joined:
    Mar 22, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Can you please explain!

    Hi Friends,

    Can you please explain why the RPAD 1st argument is simply space and why 1 is added to the salary after it is divided by 1000?

    Thanks in advance!
     
Thread Status:
Not open for further replies.

Share This Page