一张是11月份记录
一张是12月份记录我现在要查询11月份月12月分之间的数据,而且中间要和其他许多表关联,所以需要一个两表合并成一张表的视图,请问该如何创建?

解决方案 »

  1.   

    你为什么需要视图?结构一致的话
    select * from s1//11月份
    union all
    select * from s2//12月份视图的语法:
    create view V_CB_ENTINFO(C_CUS_ID,C_SUBBANK_ID,C_SUBBANK,C_CORPORATION,C_ORG_CODE,C_ECONOMYTYPE_ID,C_ECONOMYTYPE,C_INDUSTRYTYPE_ID,C_MOSTBUSINESS,C_REGISTERCAPITAL,C_SCOPE,C_CREDITDATE,C_LICENCENO,C_LICENCEDATE,C_EMPLOYEENUMBER,C_CREATEDATE,C_TAXNO,C_REGADD,C_RELATIVETYPE,C_OFFICEADD,C_CUSMGR_ID,C_CUSMGR,C_DATE,C_TIME ) as
    select EI.CustomerID as C_CUS_ID,CB.OrgID as C_SUBBANK_ID,getOrgName(CB.OrgID) as C_SUBBANK,
           EI.EnterpriseName as C_CORPORATION,n5517 as C_ORG_CODE,EI.EconomyType as C_ECONOMYTYPE_ID,
           getItemName('EconomyType',EI.EconomyType) as C_ECONOMYTYPE,EI.IndustryType ,
           MainProduction as C_MOSTBUSINESS,RegisterCapital as C_REGISTERCAPITAL,
           getItemName('Scope',Scope) as C_SCOPE,
           to_char(to_date(getDate(getMinPutOutDate(EI.CustomerID)),'yyyy/mm/dd'),'yyyy-mm-dd') as C_CREDITDATE,
           LicenceNo as C_LICENCENO,
           to_char(to_date(getDate(LicenceMaturity),'yyyy/mm/dd'),'yyyy-mm-dd')  as C_LICENCEDATE,
           EmployeeNumber as C_EMPLOYEENUMBER,
           to_char(to_date(getDate(SetupDate),'yyyy/mm/dd'),'yyyy-mm-dd') as C_CREATEDATE,
           n5519 as C_TAXNO,RegisterAdd as C_REGADD,
           OfficeTel as C_RELATIVETYPE, OfficeAdd as C_OFFICEADD,
           CB.UserID,getUserName(CB.UserID) as C_CUSMGR,
           to_char(to_date(getDate(EI.UpdateDate),'yyyy/mm/dd'),'yyyy-mm-dd') as C_DATE,
           to_char(sysdate,'yyyy-mm-dd') as C_TIME
           
    from Ent_Info EI,Customer_Belong CB,User_Info UI
           where EI.CustomerID = CB.CustomerID and CB.UserID = UI.UserID
           and   UI.status = '1'你凑合看看吧!