Hey all,
I need your precious help on an SQL query (ORACLE Database) where I do not know how to get values only for the max date grouped by article...
Here's is the query :
SELECT
vdi.articlesociete.codesociete AS code_societe,
vdi.article.code AS code_article,
vdi.prixderevient.article AS id_article,
vdi.prixderevient.depot AS art_depot,
vdi.prixderevient.datedoc,
vdi.articlefamille.designation AS famille,
vdi.articlesousfamille.designation AS sous_famille,
vdi.prixderevient.reel,
vdi.prixderevient.type,
vdi.prixderevient.societeth,
vdi.prixderevient.prixachatnet AS pa_net,
vdi.prixderevient.prixderevient AS dpr,
vdi.articlesociete.prixmoyenpondere AS pmp,
vdi.articlesociete.actifvente AS actif,
vdi.societeth.code,
vdi.societeth.nom,
vdi.depot.code AS code1,
vdi.depot.libelle,
vdi.societeth.depotprincipal
FROM
vdi.prixderevient
LEFT JOIN vdi.article ON vdi.article.pk_article = vdi.prixderevient.article
LEFT JOIN vdi.articlefamille ON vdi.articlefamille.pk_articlefamille = vdi.article.articlefamille
LEFT JOIN vdi.articlesousfamille ON vdi.articlesousfamille.pk_articlesousfamille = vdi.article.articlesousfamille
LEFT JOIN vdi.depot ON vdi.depot.pk_depot = vdi.prixderevient.depot
LEFT JOIN vdi.articlesociete ON vdi.articlesociete.articlestocke = vdi.article.pk_article
AND vdi.article.societeth = vdi.articlesociete.societeth
LEFT JOIN vdi.societeth ON vdi.societeth.pk_societeth = vdi.prixderevient.societeth
WHERE
vdi.article.code = 'PIAA6373'
AND vdi.societeth.code = 'VDIEA'
AND vdi.articlesociete.actifvente = '1'
AND vdi.prixderevient.type != '2'
Top comments (0)