I have been trying to figure out how to modify my query to get the CUSTNAME and ‘SALES TOTAL’ columns to show. Here is the current query below.
select c.CUSTNMBR, SUM(c.ortrxamt) as 'Sales Total'
from rm30101 c
inner join
(
select a.CUSTNMBR, b.CUSTNAME
from RM30101 a
inner join
RM00101 b on b.CUSTNMBR = a.CUSTNMBR
where b.ZIP = '99502' and (a.DOCDATE between '2011-01-01' and '2012-10-25')
group by a.CUSTNMBR,b.CUSTNAME
)
x on c.CUSTNMBR = x.CUSTNMBR
group by c.CUSTNMBR
order by [Sales Total] desc
I do not know how to input the column, RM00101.custname, into the first select line without receiving errors. I’ve tried replacing the ‘c.custnmbr’ with ‘x.custname’ and grouping by x.custname but the Sales Total results are waaaaaay off.
Any help would be greatly appreciated! Thank you!
-Jae
1 Answer