Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 41
  • Last Modified:

Find when the last time you received an order from a list of vendors in Crystal Reports or SQL

Our company has thousands of different vendors in its ERP system.  Many of them we no longer use.  I'm trying to figure out the best way for me to create a report that will show me a distinct list of suppliers that we have used.  Or a way to show the last time something was purchased or received from a vendor.  I can use SQL, Crystal Reports or Excel to create this but would need the thought process of what to filter the report on.   My goal is to review vendors where we have not had usage from say the past three years and eliminate them from our database.
1 Solution
Chris LuttrellSenior Database ArchitectCommented:
A few clues as to what your tables and data are like would be a huge help here.  But this is the jest of what you need to find that kind of data.
select V.Vendor, MAX(O.OrderDate) LastOrder
from VendorTable V
left outer join OrderTable O on V.ID = O.VendorID
order by MAX(O.OrderDate)
having MAX(O.OrderDate) > dateadd(YEAR, -3, CURRENT_TIMESTAMP)

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now