Hi.
I have a table wirh the following rows :
A B C D E F
-------+---------+---------+---------+---------+---------+---------+------
60201738. 4. F 20140405. 99991231 .285.
60201738. 1. P 20130401. 20131001. 285.
60201738. 2. P 20131001. 20140401. 285.
60201738. 3. P 20140401. 99991231. 285.
60201739. 1. P 20130401. 99991231. 72.
60201740. 1. P 20130401. 99991231. 272.
60201741. 1. P 20130401. 99991231. 473.
60201742. 1. P 20130401. 20131201. 118.
60201742. 2. P 20131201. 99991231. 118.
60201743. 1. P 20130401. 99991231. 118.
60201744. 1. P 20130401. 20131001. 289.
60201744. 2. P 20131001. 20140401. 289.
60201744. 3. P 20140401. 99991231. 289.
60201745. 1. P 20130401. 99991231. 73.
60201746. 1. P 20130401. 99991231. 275.
60201747. 1. P 20130401. 20131001. 293.
60201747. 2. P 20131001. 20140401. 293.
60201747. 3. P 20140401. 99991231. 293.
60201748. 1. P 20130401. 99991231. 74.
60201749. 1. P 20130401. 99991231. 279.
60201750. 1. P 20130401. 99991231. 479.
60201751. 1. P 20130401. 20131201. 120.
60201751. 2. P 20131201. 99991231. 120.
60201752. 1. P 20130401. 99991231. 120.
60201753. 1. P 20130401. 99991231. 485.
I need a SQl that can make the SUM(F) og the rows highligted. Its : all rows with a specific A but only 1 row for each A, either (with C='F') or
(C='P' AND D<=Date AND E>Date. And I can't use EXIST or NOT EXISTS
Hope it's understandable
greetz
How to retrieve the right rows ?
Moderators: Kalicharan, Moderator Group
NicC wrote:Not really because you have not used the code tags to preserve spacing.
However, pretending that it is psychic Friday, it looks as thogh you are only wanting all rows where column E = 99991231.
Code: Select all
A B C D E F
-------+---------+---------+---------+---------+---------+---------+------
60201738. 4. F 20140405. 99991231. 285.
60201738. 1. P 20130401. 20131001. 285.
60201738. 2. P 20131001. 20140401. 285.
60201738. 3. P 20140401. 99991231. 285.
60201739. 1. P 20130401. 99991231. 72.
60201740. 1. P 20130401. 99991231. 272.
60201741. 1. P 20130401. 99991231. 473.
60201742. 1. P 20130401. 20131201. 118.
60201742. 2. P 20131201. 99991231. 118.
60201743. 1. P 20130401. 99991231. 118.
60201744. 1. P 20130401. 20131001. 289.
60201744. 2. P 20131001. 20140401. 289.
60201744. 3. P 20140401. 99991231. 289.
60201745. 1. P 20130401. 99991231. 73.
60201746. 1. P 20130401. 99991231. 275.
60201747. 1. P 20130401. 20131001. 293.
60201747. 2. P 20131001. 20140401. 293.
60201747. 3. P 20140401. 99991231. 293.
60201748. 1. P 20130401. 99991231. 74.
60201749. 1. P 20130401. 99991231. 279.
60201750. 1. P 20130401. 99991231. 479.
60201751. 1. P 20130401. 20131201. 120.
60201751. 2. P 20131201. 99991231. 120.
60201752. 1. P 20130401. 99991231. 120.
60201753. 1. P 20130401. 99991231. 485.
60202439. 1. F 20130401. 99991231. 10.
No it's not about the date. If there is a row with C='F' i shall be selected and all other rows with the same A shall not be used. If there's no rows with C='F' the row with C='P' and the appropriate Date has to be selected (and onkly this row)
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page