Home » SQL & PL/SQL » SQL & PL/SQL » Please Solve query
Please Solve query [message #220971] Thu, 22 February 2007 22:50 Go to next message
mangeshkulk
Messages: 5
Registered: February 2007
Location: Pune
Junior Member
Thanks in advance please give reply for following


I have to select Last_name,salary from employees table. The salary should display in asterisks format. One asterrisk is equal to 1000 doller. So if salary of king is 9000 doller It should display 9 asterisks in following concatenated format

King*********
Re: Please Solve query [message #220973 is a reply to message #220971] Thu, 22 February 2007 22:52 Go to previous messageGo to next message
BlackSwan
Messages: 25039
Registered: January 2009
Location: SoCal
Senior Member
Why should we continue to do your homework assignments for you?

[Updated on: Thu, 22 February 2007 22:53] by Moderator

Report message to a moderator

Re: Please Solve query [message #221016 is a reply to message #220971] Fri, 23 February 2007 04:16 Go to previous messageGo to next message
mangeshkulk
Messages: 5
Registered: February 2007
Location: Pune
Junior Member
See Following will work

select last_name,salary,
CASE (SALARY/1000) when 9
then CONCAT(LAST_NAME,replace(salary,salary,'*********'))
else '*' end
from employees;


But if database contain various salary records & it will generate various results for salary/1000 then it will be very difficult to write cases and replacing number of asterisks. Is there any solution ?
Re: Please Solve query [message #221026 is a reply to message #221016] Fri, 23 February 2007 05:12 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
@Anacedent raises a good point.
If we keep doing your homework for you, then how will you learn enough to pass the exam?

So, in the spirit of helping you fail your exams, here's a solution:
SELECT last_name
      ,rpad('*',salary/1000,'*')
FROM   employees
Re: Please Solve query [message #221028 is a reply to message #221016] Fri, 23 February 2007 05:13 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
It is in fact quite easy. Search the board, this question was answered previously this week

[Edit: this was a reply to mangeshkulk; not to JRowbottom]

[Updated on: Fri, 23 February 2007 05:14]

Report message to a moderator

Previous Topic: Year Wise, Month Wise Sum of Qty Report !!
Next Topic: Sql* Loader
Goto Forum:
  


Current Time: Tue Dec 06 02:54:28 CST 2016

Total time taken to generate the page: 0.11411 seconds