Jump to content

[SOLVED] getting latest date in an item


gardan06

Recommended Posts

i currently have this code:

select c.sku,c.sku_desc,a.po_no,b.actual_vendor_code as vendor_code,unit_cost,b.receivedate as issuedbydate from sku c left outer join purchase_detail a on (c.sku=a.sku) inner join purchase_hdr b on (a.po_no=b.po_no) where b.po_status='RR_PO' and c.dept_code='2' order by c.sku,b.receivedate desc

 

but i want to group them per sku, so i tried:

select c.sku,c.sku_desc,a.po_no,b.actual_vendor_code as vendor_code,unit_cost,b.receivedate as issuedbydate from sku c left outer join purchase_detail a on (c.sku=a.sku) inner join purchase_hdr b on (a.po_no=b.po_no) where b.po_status='RR_PO' and c.dept_code='2' group by c.sku order by c.sku,b.receivedate desc

 

the problem was it didn't recognize the receivedate ordering so while it did show only one SKU item, it also showed the earliest item, not the latest.

 

i also tried:

select distinct(c.sku),c.sku_desc,a.po_no,b.actual_vendor_code as vendor_code,unit_cost,b.receivedate as issuedbydate from sku c left outer join purchase_detail a on (c.sku=a.sku) inner join purchase_hdr b on (a.po_no=b.po_no) where b.po_status='RR_PO' and c.dept_code='2' order by c.sku,b.receivedate desc

 

but the results were the same as the 1st one.

 

would anyone be kind enough to show me how to code the query in a way that only one SKU item is shown and it should be the latest one.

 

your help is greatly appreciated. thank you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.