subsitute a symbol for a set of data [message #335843] |
Thu, 24 July 2008 00:09 |
raghu2110
Messages: 5 Registered: July 2008 Location: INDIA
|
Junior Member |
|
|
Hi,
I want a solution for the following scenario
i have table called employees and i include a new column STARS,in which for every 1000 rs a star needs to be updated in the stars colums
eg:-
EMPID EMPNAME SALARY DEPTNO
----- ------------ ---------- ----------
100 raghu 20000 1
So for a salary of 20000 i need 20 stars to be updated in the new column STARS
Regards
Raghuveer
[Updated on: Thu, 24 July 2008 00:12] Report message to a moderator
|
|
|
|
Re: subsitute a symbol for a set of data [message #335851 is a reply to message #335843] |
Thu, 24 July 2008 00:36 |
raghu2110
Messages: 5 Registered: July 2008 Location: INDIA
|
Junior Member |
|
|
I have a table employees
SQL> select * from employees;
EMPID EMPNAME SALARY DEPTNO LOCATIONID COMM
---------- ------------ ---------- ---------- ---------- ----------
100 raghu 20000 1 400
101 praveen 25000 2 400
102 rajasekar 12000 3 400
103 vijay 20000 1 400
104 vijay 260000 2 400
105 shiva 28000 3 400
106 sushma 25000 1 400
107 priya 14000 4 400
108 vilva 16000 2 400
109 kumaran 26000 3 400
110 pallavi 30000 4 400
EMPID EMPNAME SALARY DEPTNO LOCATIONID COMM
---------- ------------ ---------- ---------- ---------- ----------
111 charan 25500 4 400
12 rows selected.
and i add a new column called STARS
SQL> alter table employees add stars varchar2(50);
Table altered.
SQL> desc employees
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPID NUMBER(10)
EMPNAME VARCHAR2(12)
SALARY NUMBER(10)
DEPTNO NUMBER(12)
LOCATIONID NUMBER(12)
COMM NUMBER(4)
STARS VARCHAR2(50)
Now i want to update the new column stars w.r.t salary column
for eg for emp no 100 the salary is 20000.then the stars column should have 20 stars(*)
I want the O/P to be
EMPID EMPNAME SALARY DEPTNO LOCATIONID COMM STARS
100 RAGHU 20000 1 400 ********************
[Updated on: Thu, 24 July 2008 00:37] Report message to a moderator
|
|
|
|
Re: subsitute a symbol for a set of data [message #336173 is a reply to message #335843] |
Fri, 25 July 2008 02:04 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
In the odd case that this is not a homework assignment, but a rather simplified explanation of a real-world problem, I have the following to add:
This information is already present in your table. You should NOT add another column, as this will only bring you problems. (e.g. you will have to have some mechanism to keep this extra column up-to-date when updating the salary-column)
|
|
|