Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Need to select all records belonging to a client

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Q5P418

New User


Joined: 10 May 2020
Posts: 5
Location: USA

PostPosted: Mon Jun 22, 2020 11:34 pm    Post subject: Need to select all records belonging to a client
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: 1004
Location: Richmond, Virginia

PostPosted: Tue Jun 23, 2020 12:22 am    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 2419
Location: NY,USA

PostPosted: Tue Jun 23, 2020 7:17 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Problem while trying to manipulate re... amitc23 DFSORT/ICETOOL 3 Tue Jun 30, 2020 1:19 pm
No new posts How to filter out certain records bas... manugeorge2004 JCL & VSAM 5 Wed Jun 17, 2020 10:05 pm
No new posts Need to delete inactive records from ... Sanchayita Sinha DB2 5 Fri May 29, 2020 10:47 pm
No new posts Need SQL for two latest records havin... Q5P418 DB2 10 Sun May 10, 2020 8:24 am
No new posts Compare Two datasets and Override Mat... ArunkumarGanesan DFSORT/ICETOOL 7 Mon Apr 27, 2020 7:45 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us