分类: 数据库开发技术
2009-09-07 19:35:57
使用union纵向合并,大致如下:
select ...
from
(table1 union table2)
随手写个例子,没有测试的哦,大家自己动手写吧,有错的希望大家指出:
SELECT AREA, ORGTYPE
FROM (
(SELECT AREA, ORGTYPE
FROM
(SELECT COUNT(1) AS AREA FROM COMTABLE WHERE REGAREA='GUANGDONG'),
(SELECT COUNT(2) AS ORGTYPE FROM COMTABLE WHERE ORGTYPE='TE01'))
UNION
(SELECT AREA, ORGTYPE
FROM
(SELECT COUNT(1) AS AREA FROM COMTABLE WHERE REGAREA='DONGBEI'),
(SELECT COUNT(2) AS ORGTYPE FROM COMTABLE WHERE ORGTYPE='TE02'))