Home » SQL & PL/SQL » SQL & PL/SQL » Update 7% basic Salary (SQL Plus 8.0)
icon7.gif  Update 7% basic Salary [message #651094] Wed, 11 May 2016 05:23 Go to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
Hello,
This is Salehin from Chitagong, Bangladesh

In my office we use Oracle database. In our new gazette every employee will get 7% increment on their basic when s/he complete a year. Now I want a code that can update worker basic salary on 7% when I run it. Every Month we have 250-300 worker completed a year, and I have to change their salary manually. Our salary table name is emp_payment where column name is empno,designation,grade,gross etc. And joining_date column is on emp_official table. Both table primary key is empno.

N:B: we entry gross salary on emp_payment converting gross to basic =(gross - 1100)/1.4

now pls help Embarassed



Re: Update 7% basic Salary [message #651096 is a reply to message #651094] Wed, 11 May 2016 05:29 Go to previous messageGo to next message
John Watson
Messages: 8929
Registered: January 2010
Location: Global Village
Senior Member
Please read our OraFAQ Forum Guide and How to use [code] tags and make your code easier to read

Are you familiar with the SQL language? The UPDATE statement in particular? What about JOINs and subqueries and predicate clauses?


Re: Update 7% basic Salary [message #651098 is a reply to message #651094] Wed, 11 May 2016 05:38 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
Sorry I have to say this earlier that I m new comer in this forum & also very littler knowledge on sql
Re: Update 7% basic Salary [message #651099 is a reply to message #651098] Wed, 11 May 2016 05:41 Go to previous messageGo to next message
John Watson
Messages: 8929
Registered: January 2010
Location: Global Village
Senior Member
You need to take a basic SQL course, or at least go through this doc,
http://docs.oracle.com/database/121/TDDDG/toc.htm
you can't expect to learn SQL by posting questions on a forum. That's just the way it is. I have been studying SQL for years. I will be studying it until the day I retire.
Re: Update 7% basic Salary [message #651103 is a reply to message #651099] Wed, 11 May 2016 06:26 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

... or you can just wait for a couple hours and Barbara will spoonfeed you.

Re: Update 7% basic Salary [message #651105 is a reply to message #651094] Wed, 11 May 2016 06:52 Go to previous messageGo to next message
John Watson
Messages: 8929
Registered: January 2010
Location: Global Village
Senior Member
Our colleague Barbara is a marvelous programmer (better than me) and very helpful. To make the job easier, should she choose to assist, this is how I would approach the problem.

First, write a query that will update the rows in emp_payment, applying the salary change to all rows. Can you do that?

Second, write a query that will select from emp_official only those rows for people employed for one yer (one exactly? Or is it a range?). Do that, too.

Third, use the second query as a predicate for the first query.

Job done! Have a go. Note that there may well be a better way to do it.
Re: Update 7% basic Salary [message #651106 is a reply to message #651105] Wed, 11 May 2016 07:02 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
And don't forget to work out a way of preventing continually re-applying the adjustment.

I can easily see someone coming up with something like this:

update employee
set base_pay = base_pay * 1.07
where hire_date < sysdate - 365;


So once an employee passes their anniversary date, they get a 7% raise every time the job is run. Nice. I'd like to work there!
Re: Update 7% basic Salary [message #651117 is a reply to message #651106] Wed, 11 May 2016 11:06 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
as long as the job is only run once a day the following code will work

update employee
set base_pay = base_pay * 1.07
where hire_date = add_months(trunc(sysdate),-12);
Re: Update 7% basic Salary [message #651118 is a reply to message #651117] Wed, 11 May 2016 11:14 Go to previous messageGo to next message
John Watson
Messages: 8929
Registered: January 2010
Location: Global Village
Senior Member
But! Can that algorithm handle the case of people hired on 29 Feb 2016?
Re: Update 7% basic Salary [message #651124 is a reply to message #651118] Wed, 11 May 2016 14:44 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
John Watson wrote on Wed, 11 May 2016 12:14
But! Can that algorithm handle the case of people hired on 29 Feb 2016?


It is other way around. Person hired on Feb 29 is fine:

SQL> select add_months(date '2017-02-28',-12) from dual;

ADD_MONTH
---------
29-FEB-16

SQL> 


While person hired Feb 28 of a leap year is screwed Mad :

And people hired Feb 28 a year before leap year will get raise twice Cool :

SQL> select add_months(date '2016-02-28',-12) from dual;

ADD_MONTH
---------
28-FEB-15

SQL> select add_months(date '2016-02-29',-12) from dual;

ADD_MONTH
---------
28-FEB-15

SQL> 


SY.
Re: Update 7% basic Salary [message #651127 is a reply to message #651094] Wed, 11 May 2016 15:07 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Bummer, I didn't think of that. Can do the following


update employee
set base_pay = base_pay * 1.07
where to_char(sysdate,'MMDD') <> '0229'
AND hire_date = add_months(trunc(sysdate),-12);



Thank you very much for the catch.
Re: Update 7% basic Salary [message #651128 is a reply to message #651127] Wed, 11 May 2016 15:12 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
Still, person hired Feb 28 of a leap year is screwed.

SY.
Re: Update 7% basic Salary [message #651130 is a reply to message #651128] Wed, 11 May 2016 15:49 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Check out the following article, especially the article from Laurent Schneider.

https://community.oracle.com/thread/450408?tstart=0

he came up with a fix for the leap year "bug"
Re: Update 7% basic Salary [message #651271 is a reply to message #651130] Sat, 14 May 2016 01:31 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
WOWOWOW!!!

I m really impressed that many of my bro/sis thinking about my matter......I tried on my matter that u gave me...
1st I failed to convert my Basic salary to Gross. Here some example that we convert Basic to Gross

Gross After 7% Increment on Basic new gross
5300 5510
6300 6560
6100 6350
6420 6686
6500 6770



Converting Gross to Basic is =(gross - 1100)/1.4

I again say I m newcomer on Oracle & this forum also please try to give more details..

basically our company recruit worker within 10th working day.. so dont get bother about 29th Feb....

Again thanx in advance...

[Updated on: Sat, 14 May 2016 01:41]

Report message to a moderator

Re: Update 7% basic Salary [message #651276 is a reply to message #651271] Sat, 14 May 2016 02:43 Go to previous messageGo to next message
John Watson
Messages: 8929
Registered: January 2010
Location: Global Village
Senior Member
Quote:
.I tried on my matter that u gave me...
1st I failed to convert my Basic salary to Gross.
What did you try? Show the SQL, and the result.

By the way, there is a problem with your keyboard: it inserts multiple "...." characters. There is also a problem with your spell checker, it spells "you" as "u", "thanks" as "thanx", and so on. Please correct these issues. Using that sort of thing in a professional forum is poor etiquette, and may cause problems for the many people here who are not native English speakers.
Re: Update 7% basic Salary [message #651277 is a reply to message #651276] Sat, 14 May 2016 04:24 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
SQL> update emp_payment
2 set gross = gross * 1.07
3 where joining_date = add_months(trunc(sysdate),-12);
here joining_date = add_months(trunc(sysdate),-12)
*
RROR at line 3:
RA-00904: "JOINING_DATE": invalid identifier

I think my emp_payment table dont have any joining_date column.

joining_date is in emp_official table

[Updated on: Sat, 14 May 2016 04:30]

Report message to a moderator

Re: Update 7% basic Salary [message #651295 is a reply to message #651277] Sat, 14 May 2016 19:47 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
Your entire problem is unclear. I don't even know if an update statement is what you need. It may be that you would be better off including the computation in a select statement that just uses "joining_date<=add_months(sysdate,-12)", so it would apply the formula for your computation to everybody that was hired more than a year ago. That would eliminate the need for any updates. I assume that you would use such selects for any payment schedules to be made, something like:

SELECT emp_payment.empno,  
       CASE WHEN emp_official.joining_date <= ADD_MONTHS (SYSDATE, -12) 
            THEN emp_payment.gross * 1.7 -- or whatever your actual formula is
            ELSE emp_payment.gross
       END gross
FROM   emp_payment, emp_official
WHERE  emp_payment.empno = emp_official.empno;    


Your formulas are unclear. You have only gross stored in your table. You have a formula for converting gross to basic (gross1100)/1.4. You say that you need to give a 7% raise on basic (basic*1.7) and yet you are applying the 1.7 to gross, not basic, as if you are under the misimpression that the results will be the same. You posted some sample data for gross and new gross after 7% increment on basic, but it doesn't match your formulas. You need to post a clear explanation with matching examples, step by step, of how you mathematically convert old gross to new gross.

If you do decide to do manual updates for the first 10 days of every month, then it will be something like:
UPDATE emp_payment
SET    gross = gross * 1.7 -- or whatever your actual formula is
WHERE  empno IN
       (SELECT empno 
        FROM   emp_official
        WHERE  TRUNC (joining_date) = ADD_MONTHS (TRUNC (SYSDATE), -12));

Re: Update 7% basic Salary [message #651299 is a reply to message #651295] Sun, 15 May 2016 00:50 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
/forum/fa/13126/0/

On my C2 cell I used this formula : =(B2-1100)/1.4*7%

Sorry I dont understand where should I apply my Gross to basic formula on sql.

by the way I paste the code on database it update whole empno. Should I change any thing to count only May-2015 Joining_date

thanks in advance.
  • Attachment: untitled.jpg
    (Size: 71.72KB, Downloaded 1660 times)
Re: Update 7% basic Salary [message #651308 is a reply to message #651299] Sun, 15 May 2016 11:06 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
-- test data including empno 99999 that should not receive increment:
SCOTT@orcl_12.1.0.2.0> SELECT * FROM emp_payment
  2  /

     EMPNO      GROSS
---------- ----------
     75641       5300
     75375       6300
     75321       5700
     75376       6200
     75381       6100
     75656       6420
     75382       6200
     99999       1000

8 rows selected.

SCOTT@orcl_12.1.0.2.0> SELECT * FROM emp_official
  2  /

     EMPNO JOINING_DATE
---------- ---------------
     75641 Fri 15-May-2015
     75375 Fri 15-May-2015
     75321 Fri 15-May-2015
     75376 Fri 15-May-2015
     75381 Fri 15-May-2015
     75656 Fri 15-May-2015
     75382 Fri 15-May-2015
     99999 Fri 15-Apr-2016

8 rows selected.


-- to just select the data each time you schedule payments (recommended):
SCOTT@orcl_12.1.0.2.0> SELECT p.empno,
  2  	    CASE WHEN o.joining_date <= ADD_MONTHS (SYSDATE, -12)
  3  		 THEN p.gross + (((p.gross - 1100) / 1.4) * .07)
  4  		 ELSE p.gross
  5  	    END gross
  6  FROM   emp_payment p, emp_official o
  7  WHERE  p.empno = o.empno
  8  /

     EMPNO      GROSS
---------- ----------
     75641       5510
     75375       6560
     75321       5930
     75376       6455
     75381       6350
     75656       6686
     75382       6455
     99999       1000

8 rows selected.


-- or to run once daily to permanently update the data (not recommended)
-- (you must be very careful not to update it twice):
SCOTT@orcl_12.1.0.2.0> UPDATE emp_payment p
  2  SET    p.gross = p.gross + (((p.gross - 1100) / 1.4) * .07)
  3  WHERE  empno IN
  4  	    (SELECT o.empno
  5  	     FROM   emp_official o
  6  	     WHERE  TRUNC (o.joining_date) = ADD_MONTHS (TRUNC (SYSDATE), -12))
  7  /

7 rows updated.

SCOTT@orcl_12.1.0.2.0> SELECT * FROM emp_payment
  2  /

     EMPNO      GROSS
---------- ----------
     75641       5510
     75375       6560
     75321       5930
     75376       6455
     75381       6350
     75656       6686
     75382       6455
     99999       1000

8 rows selected.

Re: Update 7% basic Salary [message #651335 is a reply to message #651308] Sun, 15 May 2016 23:42 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
Wow. Razz

Its working. But I see when I run this, my sysdate is 15-may-2016 it update only the empno of joining_date 15-may-2015. I want the whole month joining_date will be update.
Re: Update 7% basic Salary [message #651339 is a reply to message #651335] Mon, 16 May 2016 01:56 Go to previous messageGo to next message
John Watson
Messages: 8929
Registered: January 2010
Location: Global Village
Senior Member
Quote:
I want the whole month joining_date will be update.
Your subquery (or rather, BB's subquery) uses an equality predicate applie to the default result of the TRUNC functon. The default result strips off the hours-minutes-seconds part of the date. You need to use TRUNC with a non-default format, to strip off the day as well. You can look it up here,
http://docs.oracle.com/database/121/SQLRF/toc.htm
Re: Update 7% basic Salary [message #651352 is a reply to message #651339] Mon, 16 May 2016 04:47 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
I have done at last with the help of you. I make some changes have a look to my syntax

UPDATE emp_payment p
SET p.gross = p.gross + (((p.gross - 1100) / 1.4) * .07)
WHERE empno IN
(SELECT o.empno
FROM emp_official o, emp_personal ep
WHERE o.joining_date BETWEEN '01-MAY-2015' AND '30-MAY-2015'
AND O.COMPANY_NAME='Clifton Apparels Ltd'
AND EP.STATUS='Active'
and o.empno=ep.empno)
/

Now I want to take a backup of my Old gross in my emp_payment table on old_gross column. Please help me
Re: Update 7% basic Salary [message #651354 is a reply to message #651352] Mon, 16 May 2016 05:51 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
You want to store the backup at the same time you apply the raise?
If so, just set it in the same update statement.
Re: Update 7% basic Salary [message #651356 is a reply to message #651094] Mon, 16 May 2016 07:37 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
actually do it like this

UPDATE emp_payment p
SET    p.gross = p.gross + (((p.gross - 1100) / 1.4) * .07)
WHERE  empno IN
      (SELECT o.empno
       FROM   emp_official o
       WHERE  TRUNC (o.joining_date,'MONTH') = TRUNC(ADD_MONTHS (SYSDATE, -12),'MONTH'));


You would run the update ONCE a month on the first day of the month. This can be done by using dbms_job or dbms_scheduler to automatically run it.

[Updated on: Mon, 16 May 2016 07:38]

Report message to a moderator

Re: Update 7% basic Salary [message #651357 is a reply to message #651356] Mon, 16 May 2016 08:51 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
Well, as employee I do like earlier raises but I doubted employers do. Normally it would be first of next month unless employee joined first of the month (in other word first of the month after completing 12 months of service):

UPDATE emp_payment p
SET    p.gross = p.gross + (((p.gross - 1100) / 1.4) * .07)
WHERE  empno IN
      (SELECT o.empno
       FROM   emp_official o
       WHERE  TRUNC (o.joining_date,'MONTH') = TRUNC(ADD_MONTHS (SYSDATE, -13),'MONTH')
          OR  o.joining_date = TRUNC(ADD_MONTHS (SYSDATE, -12),'MONTH')
      );


But in real HR system pay is never updated. HR systems are temporal, so new row is inserted ahead of time with proper effective from & to dates and current row effective to date is updated from open ended to day before new pay takes effect. Then payroll will pickup proper pay even if employee submitted time sheet after the raise for time period before the raise.

SY.
Re: Update 7% basic Salary [message #651358 is a reply to message #651357] Mon, 16 May 2016 08:56 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
I agree, I have never seen an employee system where there was one row for pay information. every adjustment (location, amount, status...) has a new row with an effective date starting and ending date on each record. You would end the previous record by setting the effective ending date to the day before the change and start the next record on the new effective date. You can also put in a unique key on the employee ID and the effective date any your code would just grab the highest effective date. Up to you. I was just showing a possible method. I assumed this was homework.

[Updated on: Mon, 16 May 2016 08:57]

Report message to a moderator

Re: Update 7% basic Salary [message #651359 is a reply to message #651352] Mon, 16 May 2016 09:14 Go to previous messageGo to next message
John Watson
Messages: 8929
Registered: January 2010
Location: Global Village
Senior Member
Salehin wrote on Mon, 16 May 2016 10:47
I have done at last with the help of you. I make some changes have a look to my syntax

UPDATE emp_payment p
SET p.gross = p.gross + (((p.gross - 1100) / 1.4) * .07)
WHERE empno IN
(SELECT o.empno
FROM emp_official o, emp_personal ep
WHERE o.joining_date BETWEEN '01-MAY-2015' AND '30-MAY-2015'
AND O.COMPANY_NAME='Clifton Apparels Ltd'
AND EP.STATUS='Active'
and o.empno=ep.empno)
/

Now I want to take a backup of my Old gross in my emp_payment table on old_gross column. Please help me
Does Clifton Apparels Ltd work on the basis that May has only 30 days?
Re: Update 7% basic Salary [message #651360 is a reply to message #651359] Mon, 16 May 2016 09:15 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Thats simple, simply

UPDATE emp_payment p
SET p.gross = p.gross + (((p.gross - 1100) / 1.4) * .07),
p.old_gross = p.gross
WHERE empno IN
(SELECT o.empno
FROM emp_official o, emp_personal ep
WHERE o.joining_date BETWEEN '01-MAY-2015' AND '30-MAY-2015'
AND O.COMPANY_NAME='Clifton Apparels Ltd'
AND EP.STATUS='Active'
and o.empno=ep.empno)
icon14.gif  Re: Update 7% basic Salary [message #651383 is a reply to message #651094] Tue, 17 May 2016 01:46 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
Thank you all of my brothers and sisters, Specially Barbara Boehmer, Bill B .I get what I need.
Have a nice experience about this forum.

God bless you all. Smile

I will come again with new problem. Cool

Keep in touch.

Good Bye

[Updated on: Tue, 17 May 2016 01:50]

Report message to a moderator

Re: Update 7% basic Salary [message #652770 is a reply to message #651383] Sat, 18 June 2016 23:35 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
Oh its a little bit problem I am facing, When run this code
UPDATE emp_payment p
SET p.gross = p.gross + (((p.gross - 1100) / 1.4) * .07),
p.old_gross = p.gross
WHERE empno IN
(SELECT o.empno
FROM emp_official o, emp_personal ep
WHERE o.joining_date BETWEEN '01-MAY-2015' AND '30-MAY-2015'
AND O.COMPANY_NAME='Clifton Apparels Ltd'
AND EP.STATUS='Active'
and o.empno=ep.empno)
I find some fraction
/forum/fa/13167/0/
How I avoid this fraction? As usual the amount bigger than .5 is going to 1 e.i. 5877.5 will be 5878
  • Attachment: FREACTION.jpg
    (Size: 87.06KB, Downloaded 1341 times)
Re: Update 7% basic Salary [message #652771 is a reply to message #652770] Sat, 18 June 2016 23:44 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
ROUND function can do that.
Re: Update 7% basic Salary [message #652774 is a reply to message #652771] Sun, 19 June 2016 00:12 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
In anticipation of the next question, just to be clear where to put it:

UPDATE emp_payment p
SET p.gross = p.gross + ROUND(((p.gross - 1100) / 1.4) * .07),
p.old_gross = p.gross
WHERE empno IN
(SELECT o.empno
FROM emp_official o, emp_personal ep
WHERE o.joining_date BETWEEN '01-MAY-2015' AND '30-MAY-2015'
AND O.COMPANY_NAME='Clifton Apparels Ltd'
AND EP.STATUS='Active'
and o.empno=ep.empno)
Re: Update 7% basic Salary [message #652776 is a reply to message #652774] Sun, 19 June 2016 03:15 Go to previous messageGo to next message
yennhikorea
Messages: 1
Registered: June 2016
Location: vietnam
Junior Member
Can that algorithm handle the case of people hired on 29 Feb 2016?
Re: Update 7% basic Salary [message #652777 is a reply to message #652776] Sun, 19 June 2016 05:10 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

There are no people whose joined "BETWEEN '01-MAY-2015' AND '30-MAY-2015'" and have been hired on "29 Feb 2016". Smile

Re: Update 7% basic Salary [message #652783 is a reply to message #652774] Sun, 19 June 2016 13:55 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
I forgot to mention again that you need to use to_date and a format with your date strings, instead of relying on the nls_date_format for the session matching. Otherwise, someday somebody will change the nls_date_format and all of your queries will fail. I keep saying this, but you keep posting the same bad code. So, it should be (assuming that your joining_date is a truncated date):

UPDATE emp_payment p
SET p.gross = p.gross + ROUND(((p.gross - 1100) / 1.4) * .07),
p.old_gross = p.gross
WHERE empno IN
(SELECT o.empno
FROM emp_official o, emp_personal ep
WHERE o.joining_date BETWEEN TO_DATE('01-MAY-2015','DD-MON-YYYY') AND TO_DATE('31-MAY-2015','DD-MON-YYYY')
AND O.COMPANY_NAME='Clifton Apparels Ltd'
AND EP.STATUS='Active'
and o.empno=ep.empno)
Re: Update 7% basic Salary [message #652784 is a reply to message #652783] Sun, 19 June 2016 14:57 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

And to be complete, if someone has not the same language it will also fail, so:
BETWEEN TO_DATE('01-MAY-2015','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN') 
    AND TO_DATE('31-MAY-2015','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN')
or use month numbers instead of month names.

Re: Update 7% basic Salary [message #652785 is a reply to message #651094] Sun, 19 June 2016 15:03 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Salehin,

please post full results from SQL below

SELECT * FROM V$VERSION;
Re: Update 7% basic Salary [message #652807 is a reply to message #652785] Mon, 20 June 2016 04:09 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
SQL> SELECT * FROM V$VERSION;

BANNER
----------------------------------------------------------------
Personal Oracle8i Release 8.1.7.0.0 - Production
PL/SQL Release 8.1.7.0.0 - Production
CORE    8.1.7.0.0       Production
TNS for 32-bit Windows: Version 8.1.7.0.0 - Production
NLSRTL Version 3.4.1.0.0 - Production

SQL> 

Barbara thank's your advice.
Re: Update 7% basic Salary [message #652814 is a reply to message #652807] Mon, 20 June 2016 04:38 Go to previous messageGo to next message
Salehin
Messages: 62
Registered: March 2013
Location: Chittagong, Bangladesh
Member
I run barbara's code on Finishing dept.
UPDATE emp_payment p
  SET p.N_GROSS_FIN = p.N_GROSS_FIN + ROUND(((p.N_GROSS_FIN - 1100) / 1.4) * .07),
  p.gross= p.N_GROSS_FIN 
  WHERE  empno IN
  (SELECT o.empno
  FROM   emp_official o, emp_personal ep
  WHERE o.joining_date BETWEEN TO_DATE('01-MAY-2015','DD-MON-YYYY') AND TO_DATE('31-MAY-2015','DD-MON-YYYY')
 AND O.COMPANY_NAME='Clifton Apparels Ltd'
 AND EP.STATUS='Active'
 and o.section_name = 'Finishing'
 and o.ot_ent = 'Yes'
 and o.empno=ep.empno)
/
but yet I get fraction

SQL> select empno, n_gross_fin from emp_payment
  2  where empno between '00075375' and '00075391'
  3  ;

EMPNO                N_GROSS_FIN
-------------------- -----------
00075375               7702.8825
00075376               7575.3075
00075377               7702.8825
00075378               7702.8825
00075379               7575.3075
00075380                    6450
00075381               7450.8325
00075382               7575.3075
00075383               7575.3075
00075384               7575.3075
00075385               7702.8825
00075386               7575.3075
00075387               7575.3075
00075388               7702.8825
00075389               7575.3075
00075390               7855.7625
00075391                7958.085

17 rows selected.
Re: Update 7% basic Salary [message #652815 is a reply to message #652814] Mon, 20 June 2016 04:44 Go to previous messageGo to previous message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Wrong!
SQL> select  TO_DATE('01-MAY-2015','DD-MON-YYYY') from dual;
select  TO_DATE('01-MAY-2015','DD-MON-YYYY') from dual
                *
ERROR at line 1:
ORA-01843: not a valid month
Previous Topic: SQL to filter redundant key field
Next Topic: A Query for Seating Arrangement
Goto Forum:
  


Current Time: Fri Apr 19 06:31:08 CDT 2024