DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: behaviour of sql query

  1. #1
    Join Date
    Jun 2002
    Location
    VA,USA
    Posts
    83

    behaviour of sql query

    Hi ..
    Look at the queries below

    SQL> select distinct geo_reg from qmi.V_QMI_OSMO_LIGHT_NEW
    2 where user_type ='Q'
    3 and geo_reg in ('PAC','EUR','LAM','NAM')
    4 /

    no rows selected

    SQL> select distinct geo_reg from qmi.V_QMI_OSMO_LIGHT_NEW
    2 where trim(user_type) ='Q'
    3 and geo_reg in ('PAC','EUR','LAM','NAM')
    4 /

    GEO_REG
    -----------------------------------
    EUR
    LAM
    NAM
    PAC

    "qmi.V_QMI_OSMO_LIGHT_NEW" is a view

    The first one returns nothing but the second one with trim returns values ..
    can anybody explain me how this works ..
    i've verified the execution plan for the queries and its look similar .


    Thanx
    Sarav
    saravana kumar

  2. #2
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    D'nt the predicate trim(user_type) ='Q' explain you why is behaving so..
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

  3. #3
    Join Date
    Nov 2001
    Location
    Planet Earth
    Posts
    116
    what is user_type datatype? is it char?
    The man called Zorro

  4. #4
    Join Date
    Jun 2002
    Location
    VA,USA
    Posts
    83
    c'mon guys ..
    i dont know y it is behaving like this ..
    plz explain

    thanx
    sarav
    saravana kumar

  5. #5
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    Read about TRIM in the SQL Reference.
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

  6. #6
    Join Date
    Jun 2002
    Location
    VA,USA
    Posts
    83
    hi zainalj,

    The datatype for user_type is CHAR(1).
    saravana kumar

  7. #7
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    "qmi.V_QMI_OSMO_LIGHT_NEW" is a view
    How is the column defined in the view? Could you post the script?

  8. #8
    Join Date
    Jun 2002
    Location
    VA,USA
    Posts
    83
    hi dapi,
    i've attached the script of the view
    Attached Files Attached Files
    saravana kumar

  9. #9
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    wass the data type of column user_type of the table re_qmi_master_new.. are u sure its CHAR(1)?
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

  10. #10
    Join Date
    Jun 2002
    Location
    VA,USA
    Posts
    83
    SQL> desc qmi.re_qmi_master_new
    Name Null? Type
    ----------------------- -------- ----------------
    WORKBOOK_ID NOT NULL NUMBER(5)
    CREATE_DATE NOT NULL DATE
    POLE_ID NOT NULL VARCHAR2(30)
    POLE_NAME NOT NULL VARCHAR2(30)
    GEO_REG NOT NULL VARCHAR2(35)
    REGION_ID NOT NULL VARCHAR2(60)
    REGION_NAME NOT NULL VARCHAR2(60)
    DW_DISTRICT_ID NOT NULL VARCHAR2(30)
    DISTRICT_ID NOT NULL VARCHAR2(30)
    DISTRICT_NAME NOT NULL VARCHAR2(60)
    USER_TYPE NOT NULL CHAR(1)
    saravana kumar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width