Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Query Part 2. Query Topics Joining Files Defining Result Fields Complex Record Selection Formatting Output Creating Reports Using Multiple.

Similar presentations


Presentation on theme: "Introduction to Query Part 2. Query Topics Joining Files Defining Result Fields Complex Record Selection Formatting Output Creating Reports Using Multiple."— Presentation transcript:

1 Introduction to Query Part 2

2 Query Topics Joining Files Defining Result Fields Complex Record Selection Formatting Output Creating Reports Using Multiple Files

3 Joining Files Define the Query Query...... : Option..... : CREATE Library.... : KARENQRY CCSID...... : 37 Type options, press Enter. Press F21 to select all. 1=Select Opt Query Definition Option 1 Specify file selections Define result fields Select and sequence fields Select records Select sort fields Select collating sequence Specify report column formatting Select report summary functions Define report breaks Select output type and output form Specify processing options F3=Exit F5=Report F12=Cancel F13=Layout F18=Files F21=Select all

4 Joining Files Data is stored in different files  Customer Name Master Files  Customer Master Transaction Files  U4TRND – AR Detail File

5 How to Join Files Join Key Fields and ‘Like Fields’ in both files  Prevents duplicate data Transaction File is the primary file  U4TRND should be primary file  Queries run faster Use Correct type of join

6 Joining Files Types of Joins 1 – Matched Records Selects only records that have matching records in ALL the files. 2 - Matched Records with Primary File Selects every record from the primary file and includes all the matching records from all other files. 3 Unmatched Records with Primary File Selects every primary record that does not have a match in all the secondary files.

7 Joining Files Join files by key fields: U4CSTMRU4TRNDU4TRNH TDBTCHTHBTCH BATCH NO CSCNOTDCNOTHCNOCUSTOMER NO. TDINVTHINV#INVOICE NO. TDIVDTTHIVDTINVOICE DATE TDTYPETHTYPETRANS TYPE TDTMCDTHTMCDTERM CODE TDLCTHLCLOCATION

8 Define Result Fields Define the Query Query...... : Option..... : CREATE Library.... : KARENQRY CCSID...... : 37 Type options, press Enter. Press F21 to select all. 1=Select Opt Query Definition Option Specify file selections 1 Define result fields Select and sequence fields Select records Select sort fields Select collating sequence Specify report column formatting Select report summary functions Define report breaks Select output type and output form Specify processing options F3=Exit F5=Report F12=Cancel F13=Layout F18=Files F21=Select all

9 Define Result Fields Type definitions using field names or constants and operators, press Enter. Operators: +, -, *, /, SUBSTR, ||, DATE... Field Expression Column Heading Len Dec AMOUNT TDAMT*-1 AMOUNT 9 2 COMM AMOUNT*.001 COMMISSION 9 2 Bottom ____________________________________________________________________________________ Field Text Len Dec T01.TDDEPT Dept Number 3 0 T02.DPDESC Department Description 20 T01.TDITEM Item Number 14 T01.TDCNO Customer Number 7 0 More... F3=Exit F5=Report F9=Insert F11=Display names only F12=Cancel F13=Layout F20=Reorganize F24=More keys

10 Select Records Define the Query Query...... : Option..... : CREATE Library.... : KARENQRY CCSID...... : 37 Type options, press Enter. Press F21 to select all. 1=Select Opt Query Definition Option Specify file selections Define result fields Select and sequence fields 1 Select records Select sort fields Select collating sequence Specify report column formatting Select report summary functions Define report breaks Select output type and output form Specify processing options F3=Exit F5=Report F12=Cancel F13=Layout F18=Files F21=Select all

11 Complex Record Selection Select Records Type comparisons, press Enter. Specify OR to start each new group. Tests: EQ, NE, LE, GE, LT, GT, RANGE, LIST, LIKE, IS, ISNOT... AND/OR Field Test Value (Field, Number,Characters', or...) _______ _____ ________________________________________ _____ ________ _____ ________________________________________ _____ ________ _____ ________________________________________ AND’s connectOR’s separate

12 Complex Record Selection AND’s connect All statements must be true! TDITEMEQ‘HORSECHOW’ ANDTDLOCEQ001 OR’s separate Only 1 statement must be true! TDITEM EQ 'HORSECHOW' OR TDLOC EQ 001 TDITEMEQ‘HORSECHOW’ ANDTDLOCEQ001 ORTDITEMEQ‘PIG FEED' ANDTDLOCEQ002

13 Record Selection Tips U4TRND file (A/R Transaction Detail)  TDTRAN – Transaction code field 1, 2, 3, 5, 7, 8, 9  TDOFFS field – Offset records NE to 1 Used only when selecting just transaction codes Don’t need if selecting item No or G/l No.

14 Formatting Output Define the Query Query...... : Option..... : CREATE Library.... : DAWNQRY CCSID...... : 37 Type options, press Enter. Press F21 to select all. 1=Select Opt Query Definition Option Specify file selections Define result fields Select and sequence fields Select records Select sort fields Select collating sequence 1 Specify report column formatting Select report summary functions Define report breaks Select output type and output form Specify processing options F3=Exit F5=Report F12=Cancel F13=Layout F18=Files F21=Select all

15 Formatting Output Specify Report Column Formatting Type information, press Enter. Column headings: *NONE, aligned text lines Column Field Spacing Column Heading Len Dec Edit T01.TDIVDT 0 Invoice 8 0 * Date T01.TDCNO 2 Customer 7 0 Number T03.CSLKNM 2 Customer 15 Lookup Name = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Field Text Len Dec T01.TDIVDT Invoice Date 8 0 T01.TDCNO Customer Number 7 0 T03.CSLKNM Customer Lookup Name 50 T01.TDINV Invoice Number 7 0 T01.TDQTY Quantity 9/4 11 4

16 Formatting Output Define Numeric Field Editing Field........ : T01.TDIVDT Text........ : Invoice Date Heading 1...... : Invoice Heading 2...... : Date Heading 3...... : Length....... : 8 Decimal....... : 0 Sample....... : 99,999,999 Type choice, press Enter. Edit option..... 4 1=Numeric editing choices 2=Date or time editing choice 3=Edit code 4=Edit word F3=Exit F5=Report F10=Process/previous F11=Change sample F12=Cancel F13=Layout F16=Remove edit F18=Files 30

17 Formatting Output Specify Edit Word Field..... : T01.TDIVDT Heading 1.... : Invoice Length.... : 8 Heading 2.... : Date Decimal.... : 0 Heading 3.... : Type information, press Enter. (Put quotes around edit words.) (Each blank replaced by a digit, each '&' with a blank.) Edit word..... ' / / ' Edit word for summary total.. F3=Exit F5=Report F10=Process/previous F12=Cancel F13=Layout F16=Remove edit F18=Files Date not formattedFormatted Date 20,080,306 2008/03/06

18 Formatting Reports Define the Query Query...... : Option..... : CREATE Library.... : KARENQRY CCSID...... : 37 Type options, press Enter. Press F21 to select all. 1=Select Opt Query Definition Option Specify file selections Define result fields Select and sequence fields Select records Select sort fields Select collating sequence Specify report column formatting Select report summary functions Define report breaks 1 Select output type and output form Specify processing options F3=Exit F5=Report F12=Cancel F13=Layout F18=Files F21=Select all

19 Formatting Reports Define Printer Output Type choices, press Enter. Printer......... *PRINT *PRINT, name Form size: Length......... 66 Blank, 1-255 Width......... 198 Blank, 1-378 Start line........ Blank, 1-255 End line......... Blank, 1-255 Line spacing....... 1 1, 2, 3 Print definition..... N Y=Yes, N=No F3=Exit F5=Report F10=Process/previous F12=Cancel F13=Layout F18=Files NOTE: 66 Length = Portrait 51 Width = Landscape

20 Query Exercises Exercise 3  Create sales report

21 Thanks for attending!


Download ppt "Introduction to Query Part 2. Query Topics Joining Files Defining Result Fields Complex Record Selection Formatting Output Creating Reports Using Multiple."

Similar presentations


Ads by Google