select count(*) 件数, sum(qty_ordered) as 数量,(SELECT description FROM lose_reason where reason_code=wquote_item.lose_reason) as 原因
FROM wquote_item where stat='H' AND lose_reason<>'' group by lose_reason
上面的SQL语句如何加上一列,
为
每种[原因]对应的[数量]占总数量的百分比?
FROM wquote_item where stat='H' AND lose_reason<>'' group by lose_reason
上面的SQL语句如何加上一列,
为
每种[原因]对应的[数量]占总数量的百分比?
FROM wquote_item where stat='H' AND lose_reason<>'' group by lose_reason
FROM wquote_item where stat='H' AND lose_reason<>'' group by lose_reason这样呢:select count(*) 件数, sum(a.qty_ordered) as 数量,b.description as 原因,sum(a.qty_orderd)/(select sum(qty_ordered) as percent from wquote_item where stat='H' AND lose_reason<>'')
FROM wquote_item a,lose_reason b
where a.stat='H' AND a.lose_reason<>''
and b.reason_code=a.lose_reason
group by a.lose_reason,b.description
,sum(qty_ordered)/(select sum(qty_ordered) from wquote_item A where A.关键字=wquote_item.关键字)
FROM wquote_item where stat='H' AND lose_reason<>'' group by lose_reason
,sum(qty_ordered)/(select sum(qty_ordered) from wquote_item A where A.关键字=wquote_item.关键字)
FROM wquote_item where stat='H' AND lose_reason<>'' group by lose_reason===============
我想实现分组的count(*)占总的count(*)的百分比,
而不是数量的百分比。???