Vendors Used this year

Vendors Used this year

Hello all,

I have made a SQL statement to list all our vendors and the last time we used their service. The business has now requested to only show the vendors from this year. My statement still shows all vendors but if they have not been used this year the date is 'Not Assigned.'  What am I missing to filter this out?

select sd.name"Vendor Name",
apa.DOOR_NO"Address",
apa.STREET"Address2",
apa.CITY"City",
apa.STATE"State",
apa.COUNTRY"Country",
apa.POSTALCODE"Postal Code",
LONGTODATE(Select max(po.DateOrdered) from PurchaseOrder po left join VendorDefinition pvd ON po.VENDORID=pvd.VENDORID Where pvd.vendorid = sd.org_id and po.dateordered >= DATETOLONG('2017-01-01 00:01:01')) "Last Used"
from vendordefinition vd left join sdorganization sd on vd.vendorid=sd.org_id left join aaaorgcontactinfo aoci on sd.org_id=aoci.org_id left join aaacontactinfo aci on aoci.contactinfo_id=aci.contactinfo_id left join sdorgpostaladdr spa on spa.org_id=sd.org_id left join aaapostaladdress apa on apa.POSTALADDR_ID=spa.POSTALADDR_ID
Order by "Last Used" Desc

Thank you!
      • Topic Participants

      • Eric

                  New to ADSelfService Plus?