select t_trade.price,t_trade.tradename,sum(t_orderdish.amount) as total_amount,sum(t_trade.price) as total_price from t_orderdish,t_trade where t_orderdish.tableindex='"&tableindex&"'
and t_orderdish.tradeid=t_trade.tradeid
GROUP BY t_trade.price,t_trade.tradenameUnion all
Select 9999,'合计',999,sum(t_trade.price) from t_trade
and t_orderdish.tradeid=t_trade.tradeid
GROUP BY t_trade.price,t_trade.tradenameUnion all
Select 9999,'合计',999,sum(t_trade.price) from t_trade
Union all
Select 9999,'合计',999,sum(t_trade.price) from t_trade
我的意思是在我的这个sql句中既要求出sum(t_trade.price) as total_price
又要求出sum(total_price)
郁闷之极...
from t_orderdish,t_trade where t_orderdish.tableindex='"&tableindex&"'
and t_orderdish.tradeid=t_trade.tradeid
GROUP BY t_trade.price,t_trade.tradename
union
select 0,'',0,sum(t_trade.price) as total_price
from t_orderdish,t_trade where t_orderdish.tableindex='"&tableindex&"'
and t_orderdish.tradeid=t_trade.tradeid
sum(t_trade.price) as total_price,
@totalprice=@totalprice+sum(t_trade.price)
from t_orderdish,t_trade where t_orderdish.tableindex='"&tableindex&"'
and t_orderdish.tradeid=t_trade.tradeid
GROUP BY t_trade.price,t_trade.tradename
用union 是把两个结果集合并为一个