IBM i Global

IBM i Global

Connect, learn, share, and engage with IBM Power.

 View Only
Expand all | Collapse all

Runqry examples for list,value range etc.

  • 1.  Runqry examples for list,value range etc.

    Posted Wed February 26, 2025 04:03 AM

    Hi,

    Any examples for Runqry examples for list,value range etc.

    Thanks...



    ------------------------------
    jerry ven
    ------------------------------


  • 2.  RE: Runqry examples for list,value range etc.

    Posted Wed February 26, 2025 08:59 AM

    Jerry

    Here are a couple of examples




    Hope this helps some - Rich



    ------------------------------
    Rich Malloy
    Principal Systems Engineer - IBMi
    Cox Automotive
    Draper UT
    ------------------------------



  • 3.  RE: Runqry examples for list,value range etc.

    Posted Thu February 27, 2025 01:22 AM

    Thanks and what about other "value,like eq,ne etc. Examples "  any IBM I documents link for the same ?

    Thanks..




  • 4.  RE: Runqry examples for list,value range etc.

    Posted Thu February 27, 2025 08:12 AM

    You can always use F1 to get more help when you are in the RUNQRY Record Selection. Put your cursor on the VALUE field, press F1 - and you'll see examples of how to do things. For details on ALL THINGS QRY/400 - see Query for i5/OS V6R1



    ------------------------------
    Rich Malloy
    Principal Systems Engineer - IBMi
    Cox Automotive
    Draper UT
    ------------------------------



  • 5.  RE: Runqry examples for list,value range etc.

    Posted Tue March 04, 2025 03:13 AM

    Thanks,

    Let's  say field1 from file1 having multiple values and j Wan to filter records based on these multiple values then using RUNQRY how can i select such records here any example for the same please?

    Thanks...




  • 6.  RE: Runqry examples for list,value range etc.

    Posted Tue March 04, 2025 08:45 AM
    Edited by Rich Malloy Tue March 04, 2025 08:55 AM

    Jerry - That was the first example I gave you. It shows selecting values using a LIST for a field.  You had wanted to have documentation on QRY/400...I gave you a link for it...Did you read the PDF or try searching for what you are asking.  Your answer is on page 95-96. 



    ------------------------------
    Rich Malloy
    Principal Systems Engineer - IBMi
    Cox Automotive
    Draper UT
    ------------------------------



  • 7.  RE: Runqry examples for list,value range etc.

    Posted Tue March 04, 2025 09:24 AM

    Ok, Thanks.

    So using RUNQRY can we do almost all the things which can be done using SQL queries inside STRSQL Session ?

    Thanks...




  • 8.  RE: Runqry examples for list,value range etc.

    Posted Tue March 04, 2025 09:47 AM

    I don't know that I would go "that far" but if all you're interested in is selecting records from one or more files and putting the result set into an OUTFILE, Printer, or Display - then yes, you can use RUNQRY all day long for that, but..at some point..you  may want to learn how to either use SQL or at least use Query Manager Queries instead of using QRY/400

     System i: Query Management Programming



    ------------------------------
    Rich Malloy
    Principal Systems Engineer - IBMi
    Cox Automotive
    Draper UT
    ------------------------------



  • 9.  RE: Runqry examples for list,value range etc.

    Posted Thu March 06, 2025 08:14 AM

    Let's  say we need to select all the distinct values for a field using this RUNQRY then how to get such records ? Like we get in SQL : Select distinct(field name) from file name.

    Thanks...




  • 10.  RE: Runqry examples for list,value range etc.

    Posted Thu March 06, 2025 01:54 PM

    Like I said before...."I wouldn't go that far" saying RUNQRY is like SQL.

    I do not see a way of doing what you want using qry/400

    Using SQL can obviously do it but so can STRQM (query management qry). 

    Maybe someone else has an antiquated trick up their sleeve for this via qry/400 but I do not..and..it does not appear to be documented in that PDF either. 



    ------------------------------
    Rich Malloy
    Principal Systems Engineer - IBMi
    Cox Automotive
    Draper UT
    ------------------------------



  • 11.  RE: Runqry examples for list,value range etc.

    Posted Fri March 07, 2025 02:25 AM

    Sometimes you need to sit down and think about how you could solve a problem! SELECT DISTINCT is the same as SELECT ... GROUP BY without Aggregate Functions.

    Here is how you could get a result.

    Select the columns  that should be distinct,

    Sort them in the expected sequence (field1, field2 ...)

    Define the report breaks (same break level for all DISTINCT fields)

    Select Summary Report



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