How to combine queries with two columns
I want to combine some queries together into one rather than using union possibly.
Currently I'm doing something like this
select firstname, lastname, 'acc' as 'department' where dept = 'acc'
union
select firstname, lastname, 'man' as 'department' where dept = 'man'
so I get
firstname lastname department
--------------- -------------- -----------------
john doe acc
john doe man
is there a way to rewrite this so I can get something like
firstname lastname department department2
--------------- -------------- ----------------- ------------------
john doe acc man
Last edited by jtrifts; March 9th, 2013 at 03:11 PM..
Reason: spacing is wrong
|