IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need to select all records belonging to a client


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Q5P418

New User


Joined: 10 May 2020
Posts: 7
Location: USA

PostPosted: Mon Jun 22, 2020 11:34 pm
Reply with quote

Need to select all records belonging to a client having a unique value in Status column (value = P)

Code:
Name      Status

David         P
David         P
Stacy         A
Stacy         A
Curry         A
Curry         P
Curry         P
Kevin         P
Kevin         P


Result expected:

Code:
Name         Status
David         P
David         P
Kevin         P
Kevin         P
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1041
Location: Richmond, Virginia

PostPosted: Tue Jun 23, 2020 12:22 am
Reply with quote

My turn to ask: What have you tried and what were the results?

Also, what do you mean by "unique value", and why do your expected results not include all "P" records?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Jun 23, 2020 7:17 pm
Reply with quote

This is one way to get what you wanted.
Code:
SELECT A.Name, A.Status
   FROM TABLE A ,
   (SELECT Name FROM TABLE
     WHERE Status <> 'P') as B
WHERE A.Name <> B.NAME
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top