我在 SQL Server 2005 中有一个sales
包含列的表。ID,paymentType,price
create table sales(id int IDENTITY(1,1),
paymentType varchar(2),
price decimal(10,2) default(0)
)
有没有办法在一个查询中做到这一点?
SELECT SUM(price) as TE
FROM sales
WHERE paymentType = 'E'
SELECT SUM(price) as TC
FROM sales
WHERE paymentType = 'C'