duplicate query

G

Guest

I inherited a database in a mess. I ran a query to get following columns:
salesman
first date (first date of sale to company location)
last date (last date of sale to compnay location)
company location
items sold

Each salesman has an ID number which is only found in salesmantable (ID,
salesman)

first date refers to the first date salesman sold to a company, but
department within company is not listed. If the salesman sold to a second
department within the same company, he was given another first date.

My problem, the database sometimes lists just first date, same last date for
a sale. There is no overlap of dates for dates to same company, different
departments.

My dilemma is how to write a query to eliminate duplicates. I would like
salesman
first date
last date
location
items (all together for all sales to one department of one company)

Am I asking too much from one query?

Example database

salesman1 8/1/2005 8/23/2005 locationA items sold a,b,d,g
salesman2 9/1/2005 9/1/2005 locationB items solde e, z, b
salesman1 8/13/2005 8/13/2005 locationA items sold c
salesman1 8/14/2005 8/14/2005 locationC items sold a, b, d
salesman3 etc etc

I would like to see:
salesman1 8/1/2005 8/23/2005 locationA items sold a,b,c,d,g
salesman1 8/14/2005 8/14/2005 locationC items sold a,b, d
salesman2 9/1/2005 9/1/2005 locationB items sold e, z, b
salesman3 etc etc

In order to manually go through the database to get rid of duplicates will
take months as the database has over 800,000 entries, 450 salesmen, numerous
locations.

Thanks for any help.
 
G

Guest

Me again, I thought I should try to be clearer.

Looking at just one of the salemen:
salesman1 8/1/2005 8/23/2005 locationA items sold a,b,d,g
salesman1 8/13/2005 8/13/2005 locationA items sold c
salesman1 8/14/2005 8/14/2005 locationC items sold a, b, d
salesman1 8/15/2005 8/25/2005 locationA items sold a,b,c
salesman1 8/26/2005 8/29/2005 locationA items sold b,c,d
salesman1 9/13/2005 9/23/2005 locationC items sold a,b,h

Because I lack a table for departments (they are indicated by a first date
not included in a previous first date to last date, the above example
indicates that
saleman1 sold to the same department from 8/1/2005 to 8/25/2005.

so my final query needs to look like:
salesman1 8/1/2005 8/25/2005 locationA items sold a,b,c,d,g
salesman1 8/26/2006 8/29/2005 locationA items sold b,c,d
salesman1 8/14/2005 8/14/2005 locationC items sold a,b,d
salesman1 9/13/2005 9/23/2005 locationC items sold a,b,h

Again, is this possible with one query?

Thanks for any suggestions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top