Q:

Select min values for an id and for entire table in ONE query

I want to find the lowest visited value for a specific id AND the lowest for entire table.
In one query.
MyTab
ID  VISITED
101 2009
102 2010
103 2011
104 2012
105 2013

Can I do it in one query?
Right now I do like:
select
  min(visited)
from
  mytab
where
  id = 100;

and then I do the second query.
select
  min(visited)
from
  mytab;

What I want is something like below (but can one make it more simple?)
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 

Thanks

A:

You can use MIN with CASE:
select 
    min(case when id = 100 then visited end) minbyid,
    min(visited) minoverall
from mytab

SQL Fiddle Demo

