Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing Expression, Running Total Problem

Status
Not open for further replies.

heatherk

MIS
Aug 17, 2000
7
US
I am trying to get a running total column in my query for year to date but I keep coming up with the error "missing expression" on my scalar subquery. Is there something I am missing? Can anyone help?

select a.region_cd, a.sales_person, b.category_id, a.corporate_cust_id,a.cust_id, sum(c.qty), sum(c.amount),
(select sum(c1.qty) from ps_l_sales_history c1
where c1.l_year = c.l_year
and c1.l_month = c.l_month
and c.l_year = 2000 and c.l_month <= 7) rt_balance
from ps_l_rep_cust a, ps_l_rep_item b, ps_l_sales_history c
where a.setid = c.setid and
a.cust_id = c.ship_to_cust_id and
b.setid = c.setid and
b.product_id = c.product_id and
b.category_id in ('L100', 'L200', 'S100', 'S200', 'C100', 'C200')
group by a.region_cd, a.sales_person, b.category_id, a.corporate_cust_id,
a.cust_id

Thanks in Advance,
Heather
 
Sometimes using a temp table can help.
You could create one, populating all the columns except rt.balance.
Then alter the table to add that column, and run an update
using your select from ps_l_sales_history.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top