Tuesday, September 15, 2009

SQL script to show last invoice detail of every customer

Copy and paste this to SQL Server Enterprise Manager:

select distinct a.custnmbr,a.LSTTRXDT,a.lsttrxam,b.sopnumbe
from rm00103 a
join sop30200 b
on a.custnmbr = b.custnmbr and
a.LSTTRXDT = b.docdate
/* show in ascending order */
order by custnmbr asc