本身就有,比如select a.b*2 from a where xx;
成都創(chuàng)新互聯(lián)成立十多年來,這條路我們正越走越好,積累了技術(shù)與客戶資源,形成了良好的口碑。為客戶提供成都做網(wǎng)站、網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站策劃、網(wǎng)頁設(shè)計(jì)、國際域名空間、網(wǎng)絡(luò)營銷、VI設(shè)計(jì)、網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。網(wǎng)站是否美觀、功能強(qiáng)大、用戶體驗(yàn)好、性價(jià)比高、打開快等等,這些對于網(wǎng)站建設(shè)都非常重要,成都創(chuàng)新互聯(lián)通過對建站技術(shù)性的掌握、對創(chuàng)意設(shè)計(jì)的研究為客戶提供一站式互聯(lián)網(wǎng)解決方案,攜手廣大客戶,共同發(fā)展進(jìn)步。
就是顯示a表的b值的2倍。
如果想更新數(shù)據(jù)的話,可以用update set a.b=2*a.b where xx。
數(shù)據(jù)
create?table?test
(fbm?int,
fxm?varchar(10),
ftem?varchar(10),
fje?int);
insert?into?test?values?(1,'張三','吃飯',20);
insert?into?test?values?(1,'張三','睡覺',21);
insert?into?test?values?(1,'張三','起床',22);
insert?into?test?values?(4,'落筆','跑步',23);
insert?into?test?values?(5,'蘿卜','運(yùn)動',24);
commit;
語句:
select?t.*?from
(select?*?from?test
union?all
(select?fbm,fxm,'合計(jì)',sum(fje)?fje?from?test?group?by?fbm,fxm))?t
order?by?fbm,case?when?ftem?='合計(jì)'?then?1?else?0?end;
結(jié)果:
這樣?
不知道你所謂小計(jì)是什么意思,你可以看看下面的效果
select case when ID is null then '合計(jì)'
when CODE is null then '小計(jì)' else to_char(ID) end,
CODE,total
from (
select ID,CODE,sum(NUMBER) total from tttt
group by rollup(ID,CODE)
)
如果不是上面的意思 那么用開窗函數(shù)看看
SELECT ID,CODE,NUMBER
sum(NUMBER) OVER(partition by ID,CODE ORDER BY NUMBER ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
FROM tttt;
你試試
Select o.org_desc || '_' || i.b_company x,
i.trade_time,
i.cust_name,
i.order_id,
sum(i.suc_amount) over(partition by o.org_desc || '_' || i.b_company),
i.plug_id,
i.b_company,
sum(i.suc_amount) over()
from t_ec_trade_info i, t_ec_org_mapping o
where i.b_company = o.org_biz_numb
and (i.b_company is not null)
order by i.b_company desc