zoukankan      html  css  js  c++  java
  • sql连表查询找不到关联字段时?

    sql连表查询找不到关联字段时? 怎么做?

    我们可以 在查询表时虚拟一个字段,然后两个表都虚拟一个字段 ,比如new ,old对比。如图

     此图说明 应为new和old,但是new新表数据清了。。。

    对应sql:

    select * from (
    select 'new' cdrsource,to_char(BEGIN_TIME,'YYYYMMDDHH24MISS') begin_time ,FILE_NAME,CDR_TYPE_ID,FILE_SN,USER_ID,CALL_TYPE,ORG_CALLING_AREA_CODE,SERVICE_NUMBER,AREA_CODE,ORG_CALLING_NUMBER,ORG_CALLED_AREA_CODE,OPPOSE_NUMBER,OPPOSE_AREA_CODE,ORG_CALLED_NUMBER,CONNECT_NUMBER,DURATION,FEE_CODE_A,FEE_CODE_B,FEE_A,FEE_B,IMSI,IMEI,ROAM_AREA,PLMN,ROAM_TYPE,STANDARD_FEE,LONG_TYPE,FORWARD_CDR_TYPE,IS_SPECIAL,TRACK,INSERT_TIME,CHARGE_FLAG,ORG_LONG_TYPE,ORG_ROAM_TYPE,PARTITION_ID,KEYS,RATING_TIME,OFFER_ID,RESOURCE_FLAG,CARRIER_TYPE,CARRIER_NUMBER
    from CDR_voice_07
    union all
    select 'old' cdrsource,to_char(BEGIN_TIME,'YYYYMMDDHH24MISS') begin_time, FILE_NAME,CDR_TYPE_ID,FILE_SN,USER_ID,CALL_TYPE,ORG_CALLING_AREA_CODE,SERVICE_NUMBER,AREA_CODE,ORG_CALLING_NUMBER,ORG_CALLED_AREA_CODE,OPPOSE_NUMBER,OPPOSE_AREA_CODE,ORG_CALLED_NUMBER,CONNECT_NUMBER,DURATION,FEE_CODE_A,FEE_CODE_B,FEE_A,FEE_B,IMSI,IMEI,ROAM_AREA,PLMN,ROAM_TYPE,STANDARD_FEE,LONG_TYPE,FORWARD_CDR_TYPE,IS_SPECIAL,TRACK,INSERT_TIME,CHARGE_FLAG,ORG_LONG_TYPE,ORG_ROAM_TYPE,PARTITION_ID,KEYS,RATING_TIME,OFFER_ID,RESOURCE_FLAG,CARRIER_TYPE,CARRIER_NUMBER
    from CDR_voice_07_old ) where user_id = '41104000606519'
    -- and begin_time not in ('20170731232033','20170630233018','20170630233019')
    order by begin_time,cdrsource;

  • 相关阅读:
    STUN协议简介
    AssetManager asset使用
    采购申请 POCIRM-001:ORA-01403: 无论数据未找到
    Windows7在自由的虚拟机(微软官方虚拟机)
    C面试题
    热血江湖按键精灵脚本游戏!
    System.setProperty()
    Linux下patch打补丁命令
    Eclipse和PyDev搭建python开发环境
    二维数组中的查找
  • 原文地址:https://www.cnblogs.com/lgf428/p/7561545.html
Copyright © 2011-2022 走看看