How to caculate "SUM" in SQL (using WRKQRY)?
In WRKQRY command using, I have problem do not now how to implement SQL with "SUM".
I have one PF file and need to caculate sum of quantity of each Item key (After that output to one PF file). Key field is Itemkey and User
Example:
Itemkey User Quantity
0000232 1000 500
0000232 1100 600
0000232 1200 850
0000484 5000 1000
0000484 5100 1100
---
I need the result is:
0000232 1950
0000484 2100
The interface of WRKQRY as my attachment.
I know to write this SQL by using command:
SELECT item, sum(quan)
FROM item
GROUP BY item;
This is the interface of WRKQRY:
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
> SELECT OUTPUT TYPE AND OUTPUT FORM
SPECIFY PROCESSING OPTIONS
But I must implement this by WRKQRY. In WRKQRY command, I do not know where can specify SUM operator and GROUP BY (I think we must place to put SUM or AVERAGE, OR COUNT !!!)
Please help me to study more about WRKSQL.
Thanks in advance.
In WRKQRY command using, I have problem do not now how to implement SQL with "SUM".
I have one PF file and need to caculate sum of quantity of each Item key (After that output to one PF file). Key field is Itemkey and User
Example:
Itemkey User Quantity
0000232 1000 500
0000232 1100 600
0000232 1200 850
0000484 5000 1000
0000484 5100 1100
---
I need the result is:
0000232 1950
0000484 2100
The interface of WRKQRY as my attachment.
I know to write this SQL by using command:
SELECT item, sum(quan)
FROM item
GROUP BY item;
This is the interface of WRKQRY:
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
> SELECT OUTPUT TYPE AND OUTPUT FORM
SPECIFY PROCESSING OPTIONS
But I must implement this by WRKQRY. In WRKQRY command, I do not know where can specify SUM operator and GROUP BY (I think we must place to put SUM or AVERAGE, OR COUNT !!!)
Please help me to study more about WRKSQL.
Thanks in advance.






Comment