Star79
asked on
Distinct on a group by
Hello,
I have the below query:
I have the below query:
SELECT distinct
V.date_create as CREATEDDATE,
LTRIM(RTRIM(V.VENDOR_CODE)) as VENDORCODE,
V.VENDOR_NAME as VENDOR_NAME,
min(po_num),ph.date_create,ww_buyer
FROM d_vendors V
inner join m_pohead ph on V.VENDOR_CODE = ph.vendor_code
WHERE
V.date_create >= '11-01-2014'
group by v.date_create,v.vendor_code,v.vendor_name,ph.date_create,ww_buyer
order by vendorcode
Please let me know how to modify this query so that for a vendor code it returns only the least po_num ,currently its returning multiple Po's because of the grouping on each row.Po num are unique values in the m_pohead table
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.