我一直在试图弄清楚如何修改我的查询以显示 CUSTNAME 和“SALES TOTAL”列。这是下面的当前查询。
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
我不知道如何将列 RM00101.custname 输入到第一个选择行而不会收到错误。我尝试将 'c.custnmbr' 替换为 'x.custname' 并按 x.custname 分组,但销售总额结果太差了。任何帮助将不胜感激!谢谢!
-宰