| T-Sql to Pl/Sql [message #569541] |
Mon, 29 October 2012 06:08  |
 |
urko666
Messages: 2 Registered: October 2012 Location: Slovenia
|
Junior Member |
|
|
Hello. I need some help with transformation from T-Sql to Pl/Sql for the folowing queries.
--1st querry
select cast ((A.AA/B.BB) AS DECIMAL(10,2)) as "Frequency of absences per employee in 2012"
from (select SUM (value) as AA from pp_calc WHERE VP=23 and year(getdate())=2012) A,
(select COUNT (no) as BB from users) B
--2st querry
select x.Userno, x.Firstname, x.Lastname, cast (x.number /(y.number+x.number)*100 AS DECIMAL(10,2))as "% of Absence"
from
(
SELECT c.userno, u.FIRSTNAME, u.lastname, sum (c.value)/60 as number
FROM pp_calc c, users u
WHERE u.NO=c.USERNO and c.VP=22 and year(getdate())=2012
group by c.userno, u.FIRSTNAME, u.lastname
) x
join
(
SELECT c.userno, u.FIRSTNAME, u.lastname, sum (c.value)/60 as number
FROM pp_calc c, users u
WHERE u.NO=c.USERNO and c.VP=0 and year(getdate())=2012
group by c.userno, u.FIRSTNAME, u.lastname
)y on x.userno = y.userno
group by x.USERNO, x.Firstname, x.Lastname, cast (x.number /(y.number+x.number)*100 AS DECIMAL(10,2))
order by cast (x.number /(y.number+x.number)*100 AS DECIMAL(10,2)) desc
|
|
|
|
|
|
|
|
|
|
|
|