Return the earliest and latest of each product code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to find out the earliest entry date and the latest entry date for each
product code. How to do this? Currently I'm doing a primary sort by product
code and secondary sort by date, and then manually picking off the first and
last dates for each product code, but I would like to automate this.

Thanks,
Pat
 
Assuming the table is structured as such:

Product_Entry:
product_code
entry_date - date/time variable

This will get your result:
SELECT
product_code,
max(entry_date),
min(entry_date)
FROM
Product_Entry
GROUP BY
product_code

Cheers,
Jason Lepack
 
Thanks Jason, works great.

Pat

Jason Lepack said:
Assuming the table is structured as such:

Product_Entry:
product_code
entry_date - date/time variable

This will get your result:
SELECT
product_code,
max(entry_date),
min(entry_date)
FROM
Product_Entry
GROUP BY
product_code

Cheers,
Jason Lepack
 
Back
Top