Programming Languages on Power

Power Programming Languages

IBM Power, including the AIX, IBM i, and Linux operating systems, support a wide range of programming languages, catering to both traditional enterprise applications and modern development needs.


#Power

 View Only
  • 1.  include distinct values from file

    Posted Fri May 05, 2023 12:53 PM

    i have an invoice file that has the same vendor number multiple times.  how do I create a result set with just the distinct/unique values of the vendor #?



    ------------------------------
    David Strawn
    ------------------------------

    #SQL


  • 2.  RE: include distinct values from file

    Posted Fri May 05, 2023 01:31 PM

    What about:

    Select Distinct Col1, Col2, ... ColN
       from yourTable;



    ------------------------------
    Birgitta Hauser
    Database and Software Engineer
    Selfemployed - Modernization-Education-Consulting on IBM i
    Kaufering
    +49 170 5269964
    ------------------------------



  • 3.  RE: include distinct values from file

    Posted Fri May 05, 2023 02:51 PM

    I used distinct, but the vendors were still there more than once...



    ------------------------------
    David Strawn
    ------------------------------



  • 4.  RE: include distinct values from file

    Posted Fri May 05, 2023 03:05 PM

    just realized i had another column in the select statement, so the distinct was returning multiple occurs...  Will distinct list unique occurrences for vendor # for each different column in the select (that might be useful)? 



    ------------------------------
    David Strawn
    ------------------------------



  • 5.  RE: include distinct values from file

    Posted Fri May 05, 2023 06:05 PM

    If you only need the unique VendorNo, you have to specify exactly this column.
    SELECT DISTINCT VENDOR
       From ...

    If you add other columns DISTINCT will return each DISTINCT row (i.e. over all listed columns)



    ------------------------------
    Birgitta Hauser
    Database and Software Engineer
    Selfemployed - Modernization-Education-Consulting on IBM i
    Kaufering
    +49 170 5269964
    ------------------------------