Hi @Molly ,
Welcome to the microsoft TSQL Q&A forum!
Please try:
SELECT PO.VENDOR_ID,V.NAME,MAX(PO.ORDER_DATE)
from VENDOR V.
LEFT OUTER JOIN PURCHASE_ORDER PO ON V.ID = PO.VENDOR_ID
WHERE V.ACTIVE_FLAG = 'Y')
GROUP BY PO.VENDOR_ID, V.NAME
HAVING DATEDIFF(dd,MIN(PO.ORDER_DATE),MAX(PO.ORDER_DATE))>365
If this does not solve your problem,please share us your table structure (CREATE TABLE …) and some sample data(INSERT INTO …)
along with your expected result? So that we’ll get a right direction and make some test.
If you have any question, please feel free to let me know.
If the response is helpful, please click "Accept Answer" and upvote it.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.