Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have to add my thanks and appreciation for your wonderful site... People who frequent the site are the two best things - nice and smart..."

Geography

Where in the world do Tek-Tips members come from?
jasonhuibers (Programmer)
11 May 12 8:38

How can I query the following examples. I want to SELECT WHERE in the case there is a duplicate acct id - return the record with a value in Expire_DT.
Also take into consideration, if there is a duplicate acct id as in example 2 with no Expire_DT use a DISTINCT to return only one record..

Example 1
Acct_ID LName FName Expire_DT
12345 Smith John 01-May-2012
12345 Smith John

Example 2
Acct_ID LName FName Expire_DT
22222 Brown Larry
22222 Brown Larry

SantaMufasa (TechnicalUser)
15 May 12 0:38
Jason,

(Please help us help you by posting CREATE TABLE and INSERT INTO statements with your question.)

Here are data and a solution that, I believe, does what you want:

CODE

select * from acct; ACCT_ID LNAME FNAME EXPIRE_DT ------- --------------- --------------- --------- 12345 Smith John 01-MAY-12 12345 Smith John 22222 Brown Larry 22222 Brown Larry 33333 Obama Barak 02-NOV-12 44444 Romney Mitt 02-NOV-12 select Acct_ID, LName, FName, max(Expire_DT) Expire_DT from acct group by Acct_ID,LName,FName having count(*) > 1 / ACCT_ID LNAME FNAME EXPIRE_DT ------- --------------- --------------- --------- 12345 Smith John 01-MAY-12 22222 Brown Larry

Let us know if you agree that this does what you want.

santaMufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel."

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close