2013-12-10 58 views
-1

我在下面顯示我的表結構。我想要像第二個結構那樣的記錄。請幫助我使用oracle或SQL來獲取此信息。使用oracle顯示訂單計數

FLd_Date  Fld_Via Fld_Amt 
11/1/2013  cash 100.26 
11/2/2013  online 123.00 
11/3/2013  cash 32.00 
11/4/2013  cash 234.00 
11/5/2013  cash 125.00 
11/6/2013  online 125.00 
11/7/2013  cash 200.00 
11/8/2013  online 111.00 
11/9/2013  online 143.00 
11/10/2013  cash 155.00 
11/11/2013  online 12.00 
11/12/2013  online 142.00 

我想這樣

mode count total 
cash 6 846.26 
online 6 656 

回答

2
select fld_via as mode, 
     count(*) as count, 
     sum(fld_amt) as total 
from your_table 
group by fld_via 
1

輸出請嘗試:

select 
    Fld_Via as "mode", 
    count(*) as "count", 
    sum(Fld_Amt) as "total" 
from 
    YourTable 
Group by Fld_Via 
+0

檢查查詢。爲什麼現金選擇查詢-1 –

+0

現在查詢是正確的 –