SQL分组求和
/*
DROP TABLE dbo.tqty;
CREATE TABLE dbo.tqty(
row_id INT PRIMARY KEY IDENTITY(1,1),
uid VARCHAR(90) NOT NULL,
class VARCHAR(90) NOT NULL,
score DECIMAL(11, 3));
INSERT INTO tqty(uid, class, score) VALUES
('001', '1', '2'),
('001', '2', '2'),
('001', '2', '2'),
('002', '2', '2'),
('003', '2', '2'),
('002', '2', '2');
*/
SELECT uid, class, sum(score) FROM dbo.tqty GROUP BY uid, class;