R
ripon via AccessMonster.com
Hi All:
I have 2 pivot queries wich I am joining with a union. The problem is the
number of columns dont remain equal always for both pivot queries and as a
result, I am getting error in union. So can I put a blank/null for missing
pivot columns to have same number of columns for both queries all the time.
Example:
Transform sum(v_tot -v_land) as om
Select tab1.year,sum(om) as tot1
from tab1 where tab1.year=2005 or tab1.year=2006
and tab1.month=3
group by tab1.year
pivot tab1.code
union
Transform sum(v_tot -v_land) as om
Select tab1.year,sum(om) as tot1
from tab1 where tab1.year=2005 or tab1.year=2006
and tab1.month <=3
group by tab1.year
pivot tab1.code
--Sometimes the tab1.code does not have any data in tab1 and thus give non-
matching columns. Sometimes 1st part has 6 colmuns and 2nd part has 7 columns.
How can I have same num of columns to union them and the column should be in
order.
YEAR--------TOT1---------101--105---110
2005--------50000--------199--250---200
2004---------40000-------50----300--230
Thanks
I have 2 pivot queries wich I am joining with a union. The problem is the
number of columns dont remain equal always for both pivot queries and as a
result, I am getting error in union. So can I put a blank/null for missing
pivot columns to have same number of columns for both queries all the time.
Example:
Transform sum(v_tot -v_land) as om
Select tab1.year,sum(om) as tot1
from tab1 where tab1.year=2005 or tab1.year=2006
and tab1.month=3
group by tab1.year
pivot tab1.code
union
Transform sum(v_tot -v_land) as om
Select tab1.year,sum(om) as tot1
from tab1 where tab1.year=2005 or tab1.year=2006
and tab1.month <=3
group by tab1.year
pivot tab1.code
--Sometimes the tab1.code does not have any data in tab1 and thus give non-
matching columns. Sometimes 1st part has 6 colmuns and 2nd part has 7 columns.
How can I have same num of columns to union them and the column should be in
order.
YEAR--------TOT1---------101--105---110
2005--------50000--------199--250---200
2004---------40000-------50----300--230
Thanks