Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread max value use in other select
Mon, Dec 1 2014 5:15 PMPermanent Link

Mike

Hi,

I have a pricelist table and article table.

article_id   pricelist_id    
1                4                  
1                9
2                5
3                11
4                14
4                32

pricelist_id  price
4                 55
9                 2
5                 11
11               44
14               24
32               5

How can the following result be generated?

article_id   price
1               2
2               11
3               44
4               5

Per article_id the highest pricelist_id should be used.

How could this be done?

Thanks in advance.

Mike
Tue, Dec 2 2014 4:45 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mike


select a.article_id, p.price
from

(select article_id,Max(pricelist_id) as pricelist_id
from articles
group by  article_id) a


left join pricelist p on  a.pricelist_id = p.pricelist_id

Roy Lambert
Tue, Dec 2 2014 2:05 PMPermanent Link

Mike

Hi Roy,

Thank you. Will try it out.

Greetz.

Mike
Image