Return the earliest and latest of each product code

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
 
J

Jason Lepack

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top