J'ai besoin de trouver la différence entre 2 lignes spécifiques mais je ne peux pas pirater les fonctions LAG/LEAD et je ne sais pas si ces fonctions peuvent aider.Trouver la différence entre 2 lignes spécifiques
La ligne où dest = OM-OM_225 doit être soustraite de la ligne où dest = OM-OM_20.
Utilisation d'Oracle 9i.
table est créée à l'aide:
SELECT TRUNC(DATETIME,'HH') DATETIME,decode(OBJECT_ID,20,'OM-OM_20',225,'OM-OM_225',250,'OM-PSTN','OM-INT') DEST,
sum(BO) as CAABS,
SUM(BA+ RE) as CATT,
round(SUM((AC/22)*11,2) as CAMIN
FROM SCHEMA.TABLE
WHERE ((OBJECT_ID = 20) or (OBJECT_ID = 225) or (OBJECT_ID = 250) or (OBJECT_ID = 150) or (OBJECT_ID =160) or (OBJECT_ID = 161) or (OBJECT_ID = 162) or (OBJECT_ID = 163) or (OBJECT_ID = 164) or (OBJECT_ID = 165) or(OBJECT_ID = 166) or (OBJECT_ID = 167))
and DATETIME between trunc(sysdate,'hh')-1/24 and trunc(sysdate,'hh')-1/24/3600
group by TRUNC(DATETIME,'HH'), decode(OBJECT_ID,20,'OM-OM_20',225,'OM-OM_225',250,'OM-PSTN','OM-INT')
order by 1 desc
SORTIE
DATETIME DEST CAABS CATT CAMINS 9/7/2009 1:00:00 PM OM-INT 10417 64670 87971.67 9/7/2009 1:00:00 PM OM-PSTN 7372 95388 13309.17 9/7/2009 1:00:00 PM OM-OM_20 6767 231884 184952.5 9/7/2009 1:00:00 PM OM-OM_225 33104 101003 68570.83
Merci pour votre avis. –