472,331 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 software developers and data experts.

Selecting Only the First Row in a Query.


Say a number of people have 2 or 3 addresses each in a query result.
How do I select only the first address displayed for each person.

For example:

John Taylor 33 Dundas Ave.
John Taylor 55 Shane Ave.
John Taylor 786 Edward St.
Ted Charles 785 Bloor St.
Ted Charles 90 New York Ave.

All I want is the first address that is displayed for each person which
is:

John Taylor 33 Dundas Ave.
Ted Charles 785 Bloor St.

Wondering if this is possible in Access?

Marcus
******

Nov 13 '05 #1
8 62204
Marcus wrote:
Say a number of people have 2 or 3 addresses each in a query result.
How do I select only the first address displayed for each person.

For example:

John Taylor 33 Dundas Ave.
John Taylor 55 Shane Ave.
John Taylor 786 Edward St.
Ted Charles 785 Bloor St.
Ted Charles 90 New York Ave.

All I want is the first address that is displayed for each person which
is:

John Taylor 33 Dundas Ave.
Ted Charles 785 Bloor St.

Wondering if this is possible in Access?

Marcus
******


Group by name, use first of address.

--
[OO=00=OO]
Nov 13 '05 #2
Just be careful with this. I have found that in Access 2002, 'first'
returns the first record as they are stored in the *table*. I tried an
intermediate query to sort them the way I wanted and 'first' still went
back to the original table to determine which record was first.

Nov 13 '05 #3
Nunya Biznas wrote:
Just be careful with this. I have found that in Access 2002, 'first'
returns the first record as they are stored in the *table*. I tried an
intermediate query to sort them the way I wanted and 'first' still went
back to the original table to determine which record was first.


It's a lottery, first isn't ANSI SQL AFAIK and to me it says "just pull
up the first thing you find".

If there's a particular address you want for a person then that address
should be able to be identified, e.g. in my suppliers database I have
many addresses and they each have a type like Head Office, Sales, etc so
if a particular address is required then that is part of the criteria of
the query, it's not left to chance. :-)

--
[OO=00=OO]
Nov 13 '05 #4
How does one use first in Access? I tried

SELECT FIRST Name Address FROM Table .....

and it doesn't work.

Marcus
*********

Nov 13 '05 #5
Marcus wrote:
How does one use first in Access? I tried

SELECT FIRST Name Address FROM Table .....

and it doesn't work.


Like all aggregate functions, e.g.

Select First(Name) from table.

Try it in the query grid, you'll see all the options in there.

--
[OO=00=OO]
Nov 13 '05 #6
I know this is not an Access question, but does anyone know the
equivalent of the "First" aggregate in Oracle?

Marcus
********

Nov 13 '05 #7
Perhaps

SELECT * FROM TABLE WHERE ROWNUM=1

will do what you want.

Anne

"Marcus" <to*******@yahoo.ca> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I know this is not an Access question, but does anyone know the
equivalent of the "First" aggregate in Oracle?

Marcus
********

Nov 13 '05 #8
ja
Try this:

SELECT top 1 table.*
FROM table;


On 25 May 2005 10:09:39 -0700, "Marcus" <to*******@yahoo.ca> wrote:
How does one use first in Access? I tried

SELECT FIRST Name Address FROM Table .....

and it doesn't work.

Marcus
*********


Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stew | last post by:
Hi, I have a table to log sessions and user (connect_id) id's, start time etc - see below ...
2
by: karthik | last post by:
Hi, I having problems returning only the first row of data for each GROUP for the query below. Can someone please help? Thanks. SELECT bid,...
2
by: Dom | last post by:
I need to run a query based on a query in Access. The second query has a number of conditions which all work well, but there is one more contition...
8
by: Henrik Larsson | last post by:
Hi, I need help with selecting the following rows from a table looking like this: ID IP Query 1 -> 1 2.2.2.2 (ie first...
2
by: colm | last post by:
I have a string surname and want to select the first two letters to use in a code field how can i check if the second item in string is an...
6
by: Michael R | last post by:
Please help me with this. I have a form in which I would like to present results from a CrossTab query in a subform. I don't need the query to be...
9
by: Boblert | last post by:
How do I select the first word of a variable? name = raw_input("What's your full name? ") print "Hey, %s, how you doing?" % name So say I only...
3
by: khursheed | last post by:
Dears 1- I want to make a query to select first n records from a table. The table has no field like autonumber. 2- How can I use a variable in...
2
by: jgentes | last post by:
I have a query that I would like to use a union statement in to grab the number of replies to a specific thread. The initial topic thread is in a...
1
by: ziycon | last post by:
Ok, i got the main query working, my issue is that the GROUP BY isn't working, its should only show one of each location: SELECT...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.