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: 1018
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: 2772
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
This topic is locked: you cannot edit posts or make replies. Sort to include records of file 2 int... Java & MQSeries 1
No new posts Insert combined with select-max-where DB2 4
No new posts Cobol program to determine the sequen... COBOL Programming 2
No new posts Merge a variable number of records fr... DFSORT/ICETOOL 5
This topic is locked: you cannot edit posts or make replies. copy file 2 data into file1 for match... DFSORT/ICETOOL 4
Search our Forums:

Back to Top