Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I write query to generate info and write to new table?

Status
Not open for further replies.

tomsspc

Technical User
Apr 7, 2003
4
US
Hi all,

I have this information

employee(status Integer not null,
pay_rate numeric Not null,
payment_id integer not Null,
checkIn timestamp without time zone Not null,
checkOut timestamp without time zone Not null,
employee_id integer Not null);

I want calculate the salary of employees in a month (given by user) and write them to a new table called Payment.

I tried to use Select extract(epoch....) approach but I could not display the total work hours for each employee in format of hours(not timestamp format) so that i can time it with "pay_rate" to find the salary.

How can i write them to a new table?

Please help.
Thanks.
 
select
employee_id
, month
, sum(day_pay)
from
(
select
employee_id
, (checkout-checkin)*24*pay_rate day_pay
, to_char(checkin, 'MON-YY') month
)
group by employee_id, month
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top