-1
Select Sid,Sname from Salesman
Union all
Select prodId, Category from Product

In the above SQL code,I want to add another column in the resulting table named TYPE which stores S for rows from Salesman Table and P for rows from Product table.

Can anyone help!

jarlh
  • 40,041
  • 8
  • 39
  • 58

1 Answers1

3

Just add it explicitly:

Select Sid, Sname, 'Sales' as source from Salesman
Union all
Select prodId, Category, 'Product'
from Product;
Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709