Distinct
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Distinct

  1. #1
    Join Date
    Mar 2002
    Posts
    14

    Distinct

    Hi
    I'm joining two tables and selecting the key LPH.LPH_LAMPIRAN_NO as distinct. However it returns me with multiple values of the same LPH.LPH_LAMPIRAN_NO. Why is it so? Here is my statement

    Select distinct(LPH.LPH_LAMPIRAN_NO), POD.POD_REF_NO, LPH.LPH_UPLOAD_DATE, LPD.LPD_ITEM_CODE, LPH.LPH_EPO_NO, EPH.EPH_CATEGORY from T_PO_DTL POD, T_LAMPIRAN_HDR LPH, T_EPO_HDR EPH, T_LAMPIRAN_DTL LPD WHERE POD.POD_REF_NO=LPH.LPH_LAMPIRAN_NO and EPH.EPH_EPO_NO=LPH.LPH_EPO_NO and POD.POD_PO_NO = 'alpo9283 ' and LPD.LPD_LAMPIRAN_NO = POD.POD_REF_NO

    Thanks

  2. #2
    Join Date
    Feb 2001
    Posts
    180
    You are only selecting
    distinct(LPH.LPH_LAMPIRAN_NO) as distinct value.

    Make it:
    Select distinct LPH.LPH_LAMPIRAN_NO, POD.POD_REF_NO, LPH.LPH_UPLOAD_DATE, LPD.LPD_ITEM_CODE, LPH.LPH_EPO_NO, EPH.EPH_CATEGORY from ...
    Regards
    Ben de Boer

  3. #3
    Join Date
    Mar 2002
    Posts
    14
    Yeah that's what I want. Only the LPH.LPH_LAMPIRAN_NO is distinct but it returns me with LPH.LPH_LAMPIRAN_NO that is not distinct.

  4. #4
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    About what kind of result u was thinking?

    Try to undestend this situation:

    Code:
    table has fields(a,b,c)
    
    rows: a,b,c
    -----------------------
    1	2	3
    2	2	4
    2	3	5
    3	1	2
    ...
    what rows has to show oracle if u try to get
    ... espessialy for value a=2 ???:

    select distinct(a), b, c from

    Code:
    distinct(a), b, c
    -----------------------
    1	2	3
    2	?	?
    3	1	2
    ...
    This is logical nonsence.
    Last edited by Shestakov; 11-19-2002 at 11:24 AM.

  5. #5
    Join Date
    Mar 2002
    Posts
    14
    Ok I get what you mean.
    What I really want is I have two tables table1 and table2.
    I want to select field1 from table1 where it is not equal to field2 of table2. In other selecting records where fields field1 != fields field2

  6. #6
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    select t1.field1
    from table1 t1, table2 t2
    where t1.field1 <> t2.field2

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