sql server 取多个数字或者时间的最大值

SELECT MAX(b.a) from (
select distinct * from (values (1), (1), (1), (2), (5), (1), (6)) as Y(a)
) as b

SELECT MAX(b.b) from (
select distinct * from (values (1,2), (1,3), (1,4), (2,5), (5,6), (1,7), (6,8)) as Y(a,b)
) as b

SELECT MAX(b.c) from (
select distinct * from (values (1,2,3), (1,3,4), (1,4,5), (2,5,6), (5,6,7), (1,7,8), (6,8,9)) as Y(a,b,c)
) as b

SELECT MAX(b.a) from (
select distinct * from (values ('2015-1-1'), ('2015-1-2'), ('2015-1-3'), ('2015-1-4')) as Y(a)
) as b

posted @ 2015-07-08 14:14  流浪的程序员  阅读(6350)  评论(0编辑  收藏  举报