
April 26th, 2004, 12:53 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Location: NYC
Posts: 8
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Group by problem
I have a somewhat complex query that's giving me the old "Not a Group By Expression" error:
Code:
SELECT spr.rep_id, tri.inst_mnemonic,
tr.trade_date, tr.acct_id, tr.sec_key, tr.buy_sell, tr.price, tr.cusip, sum(tr.quantity), sum(tr.otc_credits), sum(tr.commission) FROM spr, sptk, tr, ac, tri, rsrt
WHERE spr.split_id = sptk.split_id AND tr.acct_id = sptk.acct_id AND tr.sec_key = sptk.sec_key AND
tr.buy_sell = sptk.buy_sell AND tr.price = sptk.price AND tr.quantity = sptk.quantity AND tr.otc_credits = sptk.otc_credits AND tr.trade_date = sptk.trade_date AND tr.reference = sptk.reference AND NOT tr.status_flag = 'D'
AND ac.acct_id = tr.acct_id AND tri.inst_id = ac.inst_id AND ( tr.otc_credits > 0 OR tr.commission > 0 )
AND rsrt.rep_id = spr.rep_id AND tr.trade_date BETWEEN '01-Jan-04' AND '30-Apr-04'
group by 1, 2, 3, 4, 5, 6, 7, 8;
I'm not sure why, given I'm using all the columns in the select. Anyone have any ideas?
|