J'essaie de sélectionner le prix le plus récent d'une autre table dans une sous-sélection. Mais je n'arrive pas à trouver comment le faire fonctionner.
C'est ce que j'ai essayé :
select something, somthingelse,
(
select * from
(
select QUOTE_PRICE as old_price
from price_history
where price_history.part_no= article_table.part_no
order by valid_from desc
) where rownum=1
)
from article_table where rownum < 5
La sous-sélection fonctionne d'elle-même, mais elle ne trouve pas les données suivantes article_table.part_no
:
Erreur SQL : ORA-00904 : "article_table ". "part_no" : identifiant invalide
Mise à jour :
Solution actuelle :
select something, somethingelse, (
SELECT MIN(QUOTE_PRICE) KEEP (DENSE_RANK FIRST ORDER BY valid_from)
FROM price_history
WHERE part_no=article_table.part_no
) as old_price
from article_table a where rownum < 5