user2180525 user2180525 - 14 days ago 5
SQL Question

How get one top numeric id from a table and date

I have this code:

SELECT TYPE, BASE_ID, PART_ID, CREATE_DATE
FROM WORK_ORDER
WHERE CREATE_DATE >'17-NOV-2016' AND WAREHOUSE_ID ='MEX-04'


and it gives as results:
enter image description here

I would like to have only one of the
base_id
per
part_id

Answer

Try this. Assuming this from your explanation.

SELECT TYPE, Max(BASE_ID) BASE_ID, PART_ID, CREATE_DATE 
FROM WORK_ORDER 
WHERE CREATE_DATE >'17-NOV-2016' AND WAREHOUSE_ID ='MEX-04'
Group By Type, Part_ID, Create_Date
Comments