表结构如下:
CREATE TABLE tempTB(
tId INT NOT NULL,
tMoney0 DECIMAL(18,2),
tMoney1 DECIMAL(18,2),
tranDate VARCHAR(20)
);
插入的数据:
INSERT INTO tempTB VALUES (1,100,0.00,'2013-2-12');
INSERT INTO tempTB VALUES (2,120,0.00,'2013-2-12');
INSERT INTO tempTB VALUES (3,0.00,1000.00,'2013-2-13');
INSERT INTO tempTB VALUES (4,100,0.00,'2013-2-13');
INSERT INTO tempTB VALUES (5,150,0.00,'2013-2-13');
INSERT INTO tempTB VALUES (6,0.00,200.00,'2013-2-13');
INSERT INTO tempTB VALUES (7,100,0.00,'2013-2-14');
INSERT INTO tempTB VALUES (8,0.00,200.00,'2013-2-14');
INSERT INTO tempTB VALUES (9,100,0.00,'2013-2-14');
INSERT INTO tempTB VALUES (10,100,0.00,'2013-3-14');
INSERT INTO tempTB VALUES (11,100,0.00,'2013-3-14');
INSERT INTO tempTB VALUES (12,100,0.00,'2013-4-14');
INSERT INTO tempTB VALUES (13,100,0.00,'2013-4-14');
现在要实现的排序效果如下:
tMoney0 tMoney1 tranDate #注释
120 0 2013-2-12
100 0 2013-2-12
220 0 2013-2-12 2月12日汇总
150 0 2013-2-13
0 1000 2013-2-13
0 200 2013-2-13
100 0 2013-2-13
250 1200 2013-2-13 2月13日汇总
100 0 2013-2-14
100 0 2013-2-14
0 200 2013-2-14 2月14日汇总
200 200 2013-2-14 3月13日汇总
670 1400 2013-2-14 2月汇总
100 0 2013-3-14
100 0 2013-3-14
200 0 2013-3-14 3月14日汇总
200 0 2013-3-14 3月汇总
100 0 2013-4-14
100 0 2013-4-14
200 0 2013-4-14 4月14日汇总
200 0 2013-4-14 4月汇总
1070 1400 总汇总
#方法一
SELECT *