我有下表
Name Val
Test1 $100.00
Test2 $200.00
Test3 $300.00
Test4 $400.00
Test5 $500.00
我可以通過以下方式按組檢索 val:
SELECT Name,sum(Val) FROM Synthese WHERE Name IN ( 'Test1' , 'Test2' , 'Test3') GROUP BY Name
這給了我以下輸出:
Name Val
Test1 $100.00
Test2 $200.00
Test3 $300.00
但我不知道該怎么做:
sum(val)/(val(Test1) val(Test2) val(Test3))
數值示例:
100/(100 200 300)
200/(100 200 300)
300/(100 200 300)
我應該怎么做 ?
uj5u.com熱心網友回復:
SELECT Name,
sum(Val)/(SELECT sum(Val) FROM Synthese WHERE Name IN('Test1','Test2','Test3'))
FROM Synthese
WHERE Name IN('Test1','Test2','Test3')
GROUP BY Name
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/329294.html
