How to use db API addExpression
Any valid SQL expression is allowed, and that includes placeholders (like in that code), literal values, or SQL functions calls (including aggregate functions, such as COUNT(*)).

$query2-&gt;addExpression(':the_group_type', 'Type', array(':the_group_type' =&gt; 'Group')) is equivalent, in plain SQL, to 'Group' AS Type.
It is an expression that is widely used in the Views module. For example, if you enable the "Add Views signature to all SQL queries" option, the query executed by the Views module will be similar to the following one. (This is the query I get for the front page view.)

SELECT node.sticky AS node_sticky, node.created AS node_created, node.nid AS nid, 'frontpage:default' AS view_name
FROM 
{node} node
WHERE (( (node.promote &lt;&gt; '0') AND (node.status = '1') ))
ORDER BY node_sticky DESC, node_created DESC
LIMIT 10 OFFSET 0


The 'frontpage:default' AS view_name part is added using SelectQuery::addExpression() in a way similar to what the code you show does.