我想找到特定 id 的最低访问值和整个表的最低值。在一个查询中。
我的标签
ID VISITED
101 2009
102 2010
103 2011
104 2012
105 2013
我可以在一个查询中完成吗?
现在我确实喜欢:
select
min(visited)
from
mytab
where
id = 100;
然后我做第二个查询。
select
min(visited)
from
mytab;
我想要的是下面的东西(但可以让它更简单吗?)
select
min( a.visited ),
min( b.visited )
from
(select visited from mytab where id=100) as a,
(select visited from mytab) as b;
Query run for e.g. id 103 and 100 would be:
id 103 will give 2011,2009
id 100 will give null,2009
谢谢