A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Distinct rows



 
 
Thread Tools Display Modes
  #1  
Old August 19th, 2009, 04:51 PM posted to microsoft.public.access.gettingstarted
MurdocUK via AccessMonster.com
external usenet poster
 
Posts: 6
Default Distinct rows

Hi,

I'm a bit new to databases, hope someone can help.

I have a query which joins two tables showing applications (defined by a
reference number) that have had mail merge letters sent. I want to modify
this query as some applications have had more than one mail merge letter sent
to more than one recipient (Consultee field).

The two tables are joined on year, ref and district. I would like year, ref
and district to be DISTINCT whilst still displaying the rest of the fields on
the DISTINCT row.

To elaborate, the output from the query is currently: -

Year Ref District Consultee DecType App_Type Cat
2006 43 S EA APST PN 3
2006 44 S AP APRM RMM 1
2006 44 S FS APRM RMM 2
2006 44 S ST APRM RMM 2
2006 44 S AP APRM RMM 5
2006 44 S BW APRM RMM 6
2006 44 S GU APRM RMM 7
2006 45 S NULL APPM FULL 8

I would like the output to list all of the fields but only one row for each
application i.e.

Year Ref District Consultee DecType App_Type Cat
2006 43 S EA APST PN 3
2006 44 S AP APRM RMM 1
2006 45 S NULL APPM FULL 8

There are other fileds in the tables but I have removed them for ease.

Thanks in advance,
Murdoc.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...arted/200908/1

  #2  
Old August 19th, 2009, 05:07 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 7,815
Default Distinct rows

Probably all you need to do is to add the DISTINCT key word to your query.

Since you are new, you are probably not working in the SQL view.

Open your query in Design view
Right click on the gray area that is displaying the tables (not on one of the
tables) and show properties.
In the QUERY's property list set Unique Values property to Yes

Or open the query in SQL view (View; SQL from the menu)

Insert the word DISTINCT after the word SELECT

SELECT Distinct YourFieldA, YourFieldB, ....

If that does not work, copy the SQL statement and post it so someone can
suggest alternatives.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

MurdocUK via AccessMonster.com wrote:
Hi,

I'm a bit new to databases, hope someone can help.

I have a query which joins two tables showing applications (defined by a
reference number) that have had mail merge letters sent. I want to modify
this query as some applications have had more than one mail merge letter sent
to more than one recipient (Consultee field).

The two tables are joined on year, ref and district. I would like year, ref
and district to be DISTINCT whilst still displaying the rest of the fields on
the DISTINCT row.

To elaborate, the output from the query is currently: -

Year Ref District Consultee DecType App_Type Cat
2006 43 S EA APST PN 3
2006 44 S AP APRM RMM 1
2006 44 S FS APRM RMM 2
2006 44 S ST APRM RMM 2
2006 44 S AP APRM RMM 5
2006 44 S BW APRM RMM 6
2006 44 S GU APRM RMM 7
2006 45 S NULL APPM FULL 8

I would like the output to list all of the fields but only one row for each
application i.e.

Year Ref District Consultee DecType App_Type Cat
2006 43 S EA APST PN 3
2006 44 S AP APRM RMM 1
2006 45 S NULL APPM FULL 8

There are other fileds in the tables but I have removed them for ease.

Thanks in advance,
Murdoc.

  #3  
Old August 20th, 2009, 04:07 PM posted to microsoft.public.access.gettingstarted
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Distinct rows

In looking at the data you posted a totals query might do you.
Open your query in design view and click on the icon that looks like an 'M'
on its side - ∑ to change to a totals query.
Then change the Group By for all fields except Year, Ref, and District to
First.
Run the query and see if the results are what you want.

--
Build a little, test a little.


"MurdocUK via AccessMonster.com" wrote:

Hi,

I'm a bit new to databases, hope someone can help.

I have a query which joins two tables showing applications (defined by a
reference number) that have had mail merge letters sent. I want to modify
this query as some applications have had more than one mail merge letter sent
to more than one recipient (Consultee field).

The two tables are joined on year, ref and district. I would like year, ref
and district to be DISTINCT whilst still displaying the rest of the fields on
the DISTINCT row.

To elaborate, the output from the query is currently: -

Year Ref District Consultee DecType App_Type Cat
2006 43 S EA APST PN 3
2006 44 S AP APRM RMM 1
2006 44 S FS APRM RMM 2
2006 44 S ST APRM RMM 2
2006 44 S AP APRM RMM 5
2006 44 S BW APRM RMM 6
2006 44 S GU APRM RMM 7
2006 45 S NULL APPM FULL 8

I would like the output to list all of the fields but only one row for each
application i.e.

Year Ref District Consultee DecType App_Type Cat
2006 43 S EA APST PN 3
2006 44 S AP APRM RMM 1
2006 45 S NULL APPM FULL 8

There are other fileds in the tables but I have removed them for ease.

Thanks in advance,
Murdoc.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...arted/200908/1


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.