0
我質疑的表用下面的查詢SQL:基於列的值嵌套查詢
select content_type_code_id
, price
, count(price) AS PRICECOUNT
from dbo.transaction_unrated
where transaction_date >= '2012/05/01'
and transaction_date < '2012/06/01'
and content_provider_code_id in (1)
group by content_type_code_id, price
ORDER BY price ASC
產生以下結果集
content_type_code_id price PRICECOUNT
1 -1.99 1
1 -0.99 1
1 0.99 178
1 1.99 786
但我想設置這樣的結果:
content_type_code_id price Debits Credits
1 0.99 178 1
1 1.99 786 1
(負價格爲信貸和積極的價格作爲借方)