p*t
2 楼
Given the following table, TRADE:
TRADE
Account BuySell Quantity
------- ------- --------
XXX B 500
XXX S 100
YYY S 1100
ZZZ S 300
Outline the SQL required to produce the following output:
Account Position
------- --------
XXX 400
YYY -1100
ZZZ -300
谢谢了。
TRADE
Account BuySell Quantity
------- ------- --------
XXX B 500
XXX S 100
YYY S 1100
ZZZ S 300
Outline the SQL required to produce the following output:
Account Position
------- --------
XXX 400
YYY -1100
ZZZ -300
谢谢了。
B*g
4 楼
SELECT t.account,SUM(CASE t.buysell WHEN 'B' THEN t.quantity ELSE t.quantity
*-1 END) Position
FROM trade t
GROUP BY t.account
【在 p*****t 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: Given the following table, TRADE:
: TRADE
: Account BuySell Quantity
: ------- ------- --------
: XXX B 500
: XXX S 100
: YYY S 1100
: ZZZ S 300
: Outline the SQL required to produce the following output:
: Account Position
*-1 END) Position
FROM trade t
GROUP BY t.account
【在 p*****t 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: Given the following table, TRADE:
: TRADE
: Account BuySell Quantity
: ------- ------- --------
: XXX B 500
: XXX S 100
: YYY S 1100
: ZZZ S 300
: Outline the SQL required to produce the following output:
: Account Position
a*o
7 楼
受益匪浅,以前只在PL/SQL里用过一点CASE,这种写法不熟,多谢。
相关阅读
兩台 19" 彩顯 可以怎麼玩?SQL and C# Programmer Needed公司的IT部门急招一个Developer (转载)测一下你的t-sql 功力38岁老loser想转行,如果学计算机类是不是不明智mysql 问题 (转载)哪位试过在win 7上装sybase ase 15?sybase 问题请教好冷清请教:家庭网络solution (转载)NOLOCK为什么不是蓝色的?mysql里可以count多个区间吗log shipping 问题Need help of mysql cluster installation!!Oracle RAC question (vip related)想考70-433,在电驴上找不到资料和题库,哪位能帮忙怎么写这个query呢?请教Access ReportHow to write this query in Oracle?database server access internet 的问题