Home » SQL & PL/SQL » SQL & PL/SQL » inserting values into tables
icon3.gif  inserting values into tables [message #247493] Tue, 26 June 2007 02:23 Go to next message
pjsurve
Messages: 2
Registered: June 2007
Location: INDIA
Junior Member
hi,
i have one question
in the emp table i have to create new column named stars. in this column i have to enter stars(*) i.e. asterisks according to sal.
e.g.
if sal is 800 then 8 stars should be entered in that column or if sal is 1250 the 13 stars should be entered in that column.
i think a lot over it but could not find any solution please help me!
Re: inserting values into tables [message #247495 is a reply to message #247493] Tue, 26 June 2007 02:32 Go to previous messageGo to next message
sanka_yanka
Messages: 184
Registered: October 2005
Location: Kolkata
Senior Member

user the following query to retrive the string
select sal,trim(lpad(' ',ceil(sal/100),'*')) as stars  from emp;

[Updated on: Tue, 26 June 2007 02:32]

Report message to a moderator

Re: inserting values into tables [message #247498 is a reply to message #247493] Tue, 26 June 2007 02:38 Go to previous messageGo to next message
Michel Cadot
Messages: 64098
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> select sal, lpad('*',round(sal/100),'*') star from scott.emp;
       SAL STAR
---------- --------------------------------------------------
       800 ********
      1600 ****************
      1250 *************
      2975 ******************************
      1250 *************
      2850 *****************************
      2450 *************************
      3000 ******************************
      5000 **************************************************
      1500 ***************
      1100 ***********
       950 **********
      3000 ******************************
      1300 *************

14 rows selected.

Regards
Michel
Re: inserting values into tables [message #248836 is a reply to message #247498] Mon, 02 July 2007 05:09 Go to previous message
pjsurve
Messages: 2
Registered: June 2007
Location: INDIA
Junior Member
thanks
Previous Topic: for real time information.
Next Topic: group by on date
Goto Forum:
  


Current Time: Fri Dec 02 12:15:03 CST 2016

Total time taken to generate the page: 0.05709 seconds