Solved

Hiding all But First Instance of Duplicate Values in a Column

Posted on 2007-03-20
3
213 Views
Last Modified: 2008-07-03
I have a sql statement that reads : select rep1, prep1, owner, parcel1, created from tblprofiledata where created >= '2007-02-01' and created < '2007-03-01' order by rep1, prep1

Say it returns the following results:
rep1       prep1      owner      parcel1      created
Alpine      John A      Joe B      2345      2/1/2007
Alpine      Kara K      Max K            4897      2/4/2007
Alpine      Mandy L      Kathy S      7894      2/10/2007
Coldwell      Brandy B      Louis L      7854      2/4/2007
Faulkin      Jerry K      Tabatha S      9832      2/12/2007
Faulkin      Jerry K      Martha S      9823      2/14/2007

I would like the results to display so that only the first instance of each unique value in the rep1 and prep1 columns are displayed.  So I want the results to display something like this:

rep1       prep1      owner      parcel1      created
Alpine      John A      Joe B      2345      2/1/2007
                     Kara K      Max K           4897      2/4/2007
      Mandy L      Kathy S      7894      2/10/2007
Coldwell      Brandy B      Louis L      7854      2/4/2007
Faulkin      Jerry K      Tabatha S      9832      2/12/2007
                           Martha S      9823      2/14/2007

Is it possible to do something like that with a SQL statement?
0
Comment
Question by:ckangas7
3 Comments
 
LVL 15

Accepted Solution

by:
DonKronos earned 250 total points
Comment Utility
No.  This is something you would do in your report writer or your program.
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
One way: You decide which value for the other columns should be displayed. With that, you can use something like:

select rep1, prep1, min(owner), min(parcel1), min(created) from tblprofiledata
where reated >= '2007-02-01' and created < '2007-03-01'
group by rep1, prep1
order by rep1, prep1;
0
 

Author Comment

by:ckangas7
Comment Utility
The min statement won't quite do what I need it to, but thanks.  Will have to look into other options.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now