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

Posted on 2017-06-14
Medium Priority
Last Modified: 2017-06-14
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.
Question by:ITworks
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 27

Accepted Solution

Chris Luttrell earned 2000 total points
ID: 42177276
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


Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question