『壹』 sql怎麼統計各類銷售利潤
select number,(sum(sell_price) - count(sell_price) * (select in_price from phone where number = s.number)) as profit from sales as s group by number;
利潤計算規則:
按手機型號計算累計銷售額sum(sell_price)
-
按手機型號計算累計銷售量count(sell_price) * 進貨價 (select in_price from phone where number = s.number)
= 銷售利潤
『貳』 如何用SQL語句統計總金額和區段金額
select合同ID,SUM(收費金額)as總金額,(selectsum(收費金額)from收費whereDATEPART(yy,收費時間)=2013anda.合同ID=收費.合同ID)as年度金額
from收費asagroupby合同ID
『叄』 sql如何按地區統計銷售額
時間是什麼格式?如果是datetime的話,資料庫是mysql還是sqlserver?
sqlserver的話:
selecttop5region,sum(totalprice)from[order]whereyear(requireddate)=xxxxorderbysum(totalprice)desc
mysql的話:
selectregion,sum(totalprice)from[order]whereyear(requireddate)=xxxxorderbysum(totalprice)desclimit5
『肆』 請問 sqlserver 各個商品各月銷售額統計 sql語句怎麼寫
可以完成,思路如下:
通過pid 商品編碼分組,得到銷售日期的每個月列,後用sum(caseFact_mWHEN月份 then數量end)來操作即可.
--年度售額:
selectpid商品編碼
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'01'thencCostend)),0)'countCost_1'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'02'thencCostend)),0)'countCost_2'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'03'thencCostend)),0)'countCost_3'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'04'thencCostend)),0)'countCost_4'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'05'thencCostend)),0)'countCost_5'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'06'thencCostend)),0)'countCost_6'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'07'thencCostend)),0)'countCost_7'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'08'thencCostend)),0)'countCost_8'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'09'thencCostend)),0)'countCost_9'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'10'thencCostend)),0)'countCost_10'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'11'thencCostend)),0)'countCost_11'
,isnull(convert(dec(18,2),sum(caseFact_mWHEN'12'thencCostend)),0)'countCost_12'
,isnull(convert(dec(18,2),sum(cCost)))'countTotal'
fromTabgroupbypid
--Fact_m指的就是銷售日期[月],最後還有一列為年度總計
希望能幫到你!
『伍』 如何用sql統計總金額
1、如果你是要統計當日銷售總金額,如下:
select
sum(piece*price)
as
'當日銷售總額'
from
當日銷售表
where
date='07/5/16'
2、如果你是要統計各商品當日的銷售額,如下:
select
rq,sno,sname,sum(piece)
as
piece,sum(piece*price)
as
'銷售額'
from
當日銷售表
group
by
rq,sno,sname
『陸』 如何用sql語句統計出一個部門的總銷售額
select dept,sum(mny) mny from sale
group by dept
『柒』 sql 查詢問題(根據名稱去統計銷售金額)
select銷售ID,銷售人,銷售時間=max(銷售時間),銷售金額=sum(銷售金額)from銷售表
GROUPBY銷售ID,銷售人
『捌』 SQL如何統計某段時間某業務員銷售總額、指定商品銷售額及該商品佔比
select 業務員,銷售總量,A產品銷售數量,(A產品銷售數量/銷售總量,) as A產品佔比 from (select 業務員,sum(銷售數量) as 銷售總量,(select sum(銷售數量) from tablename where a.業務員=業務員 and 產品='A' group by 業務員) as A產品銷售數量 from tablename a where 業務員='張三' group by 業務員) a
『玖』 SQL如何統計某段時間某業務員銷售總額、指定商品銷售額及該商品佔比
select
業務員,銷售總量,A產品銷售數量,(A產品銷售數量/銷售總量,)
as
A產品佔比
from
(select
業務員,sum(銷售數量)
as
銷售總量,(select
sum(銷售數量)
from
tablename
where
a.業務員=業務員
and
產品='A'
group
by
業務員)
as
A產品銷售數量
from
tablename
a
where
業務員='張三'
group
by
業務員)
a