select Field1,
sum(
Field2 *
case when Field1 like 'Condition1' then val1
when Field1 like 'Condition2' then val2
end
)
from table
where Field1 like 'Codition1' or Field1 like 'Condition2'
group by Field1
※ 引述《licheer (Keep The Faith)》之銘言:
: 資料庫名稱:MSSQL
: Select Field1, SUM(Field2 * val) // val 變數
: From Table
: Where
: Field1 like 'Condition1'
: or
: Field1 like 'Condition2'
: Group by Field1
: Field0 Field1 Field2 val1 val2
: