How to order unions separately in db_select?
I found the answer not in Drupal, but in MySQL:

I added a new column to the subqueries with an indicator of the query. The first sub query has the sort column value "0_" and the second one "1_".

Here is the drupal db_select code:

$subquery1 = db_select('tab1','t1');
$subquery1-&gt;fields('t1',array('id','fname');
$subquery1-&gt;where('fname=:fname',array(':fname'=&gt;'Frank');
$subquery1-&gt;addExpression("'0_'",'sort_column');

$subquery2 = db_select('tab2','t2');
$subquery2-&gt;fields('t2',array('id','fname');
$subquery2-&gt;where('lname=:lname',array(':lname'=&gt;'Sinatra');
$subquery2-&gt;addExpression('1_','sort_column');
$subquery2-&gt;orderBy('sort_column', 'ASC');
$subquery2-&gt;orderBy('fname','DESC');

$subquery1-&gt;union($subquery2);

$result = $subquery1-&gt;execute();
...