how to retrieve the first and last instance of a row in pdo dataset



PHP Snippet 1:

select part,cost,description,date_received,qty_received
from v_po_history 
where part not like '*%' and date_received >= '2022-04-01' and date_received <= '2022-04-30' and location = 'HS' 
order by part, date_received asc

PHP Snippet 2:

select part,min(cost) as Lowest_Cost,max(cost) as Highest_Cost, min(date_received) as First_date, max(date_received) as Last_Date, description, (max(cost) - min(cost)) as Difference
from v_po_history 
where part not like '*%' and date_received >= '2022-04-01' and date_received <= '2022-04-30' and location = 'HS'
group by part,description