Home » Other » Training & Certification » subsitute a symbol for a set of data
subsitute a symbol for a set of data [message #335843] Thu, 24 July 2008 00:09 Go to next message
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 #335844 is a reply to message #335843] Thu, 24 July 2008 00:13 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & follow Posting Guideline as stated in URL above
Re: subsitute a symbol for a set of data [message #335851 is a reply to message #335843] Thu, 24 July 2008 00:36 Go to previous messageGo to next message
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 #335861 is a reply to message #335843] Thu, 24 July 2008 00:51 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

This is a classical homework, post what you aready tried, I encourage you to have a look at SQL functions list.

Regards
Michel
Re: subsitute a symbol for a set of data [message #336173 is a reply to message #335843] Fri, 25 July 2008 02:04 Go to previous message
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)
Previous Topic: Oracle Certification
Next Topic: Query NOT as per Client logic..plz help (merged 3 cross-posts by bb)
Goto Forum:
  


Current Time: Tue Apr 23 12:10:58 CDT 2024