Create Table Test(Col1 datetime default NULL,col2 varchar(16) default null);
insert into test value
(“2016-03-16 10:26:00”, “A002”),
(“2016-03-16 13:16:00”, “A002”),
(“2016-03-16 13:18:00”, “A002”),
(“2016-03-16 13:16:00”, “A002”),
(“2016-03-16 13:16:00”, “A003”),
(“2016-03-16 13:16:00”, “A005”),
(“2016-03-15 17:09:00”, “A008”),
(“2016-03-16 10:26:00”, “A010”),
(“2016-03-16 10:26:00”, “A011”),
(“2016-03-15 17:09:00”, “B010”);
按时间先的排前面,COL2
正确输出:
“2016-03-15 17:09:00”, “A008”
“2016-03-15 17:09:00”, “B010”
“2016-03-16 10:26:00”, “A002”
“2016-03-16 13:16:00”, “A002”
“2016-03-16 13:16:00”, “A002”
“2016-03-16 13:16:00”, “A002”
“2016-03-16 10:26:00”, “A010”
“2016-03-16 10:26:00”, “A011”
“2016-03-16 13:16:00”, “A003”
“2016-03-16 13:16:00”, “A005”
insert into test value
(“2016-03-16 10:26:00”, “A002”),
(“2016-03-16 13:16:00”, “A002”),
(“2016-03-16 13:18:00”, “A002”),
(“2016-03-16 13:16:00”, “A002”),
(“2016-03-16 13:16:00”, “A003”),
(“2016-03-16 13:16:00”, “A005”),
(“2016-03-15 17:09:00”, “A008”),
(“2016-03-16 10:26:00”, “A010”),
(“2016-03-16 10:26:00”, “A011”),
(“2016-03-15 17:09:00”, “B010”);
按时间先的排前面,COL2
正确输出:
“2016-03-15 17:09:00”, “A008”
“2016-03-15 17:09:00”, “B010”
“2016-03-16 10:26:00”, “A002”
“2016-03-16 13:16:00”, “A002”
“2016-03-16 13:16:00”, “A002”
“2016-03-16 13:16:00”, “A002”
“2016-03-16 10:26:00”, “A010”
“2016-03-16 10:26:00”, “A011”
“2016-03-16 13:16:00”, “A003”
“2016-03-16 13:16:00”, “A005”
解决方案
10
直接select * from Test order by Col1;
应该就行了啊
应该就行了啊
30
select * from Test order by Col1 ,Col2