回 帖 发 新 帖 刷新版面

主题:sql中union多个(2个以上)表的联合查询

create table zw.tab1 as
select distinct callerno from icd.tbilllog5 where substr(callerno,1,1)=1
union 
select distinct callerno from icd.tbilllog6 where substr(callerno,1,1)=1
union 
select distinct callerno from icd.tbilllog7 where substr(callerno,1,1)=1
union 
select distinct callerno from icd.tbilllog8 where substr(callerno,1,1)=1
union 
select distinct callerno from icd.tbilllog9 where substr(callerno,1,1)=1
union
select distinct callerno from icd.tbilllog10 where partid<11 having by substr(callerno,1,1)=1;
其中icd.tbilllogX表示每个月的数据表,icd.tbilllog10 where partid<11 表示10月1日到10日的数据,
substr(callerno,1,1)=1表示要查询的callerno的第一个是1;但是运行说有错误。
求解释解决谢谢!

回复列表 (共1个回复)

沙发

求解决,谢谢!各位大侠

我来回复

您尚未登录,请登录后再回复。点此登录或注册