One more thing all data comes from one table and tble a,b,c I have created from different period such as this year, last year, this month. What would be the best way to do this???
select name, sales as tbl1
from tbl1
union all
select name, sales as tbl2
from tbl2
union all
select name, sales as tbl3
from tbl3
in fact, you could probably adapt this so that you wouldn't need to split the data out of the original table into three tables, you could just do it in three WHERE clauses above...
select name, sales, 'tbl1' as tablename
from tbl1
union all
select name, sales, 'tbl2' as tablename
from tbl2
union all
select name, sales, 'tbl3' as tablename
from tbl3
Hey thanks for the reply and try the second method but it gives me the sum of the sales amout instead of the result I want. Am I doing something wrong?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.