473,659 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 63439
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*******@yaho o.ca> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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*******@yaho o.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
1216
by: Stew | last post by:
Hi, I have a table to log sessions and user (connect_id) id's, start time etc - see below +---------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+-------+ | connect_id | varchar(12) | | | | | | session_id | varchar(32) | | | | |
2
31519
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, xact_date, xact_time FROM badge_history bh GROUP BY bid, xact_date, xact_time ORDER BY bid, xact_date DESC, xact_time DESC So if the data returned by the above query is:
2
18693
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 I need to set to make it run properly. the first query returns a number of data items, consisting, among other fields, of a Company_ID and a Rating_Date. For most companies, the latest value of Rating_Date is equal to a value in a seperate table (tblVariables) which logs the last time a...
8
2220
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 IP 1 1.1.1.1 <- Query 2 for each ID) 1 3.3.3.3 (ie second IP for each ID) -> 2 5.5.5.5 2 6.6.6.6 <-
2
2750
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 apostrophe and filter it out ' in names such as o'brien and use the third item in string so i get ob in other words if surname = brown code =br but if surname = o'brien code = ob colm
6
2831
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 bounded to a master field. Also, I have a parameter in the query as one of the main form controls. Please look at the query: PARAMETERS !! Long; TRANSFORM Sum(LoansSumAmountAndYearAndCity.Amount) AS SumOfAmount SELECT LoansSumAmountAndYearAndCity.Customers.Id,...
9
2748
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 wanted it to print the first name? How would I do this not knowing the amount of letters in it?
3
3784
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 query. for example n=100 n is a variable SELECT * FROM table WHERE numericfield>n
2
1645
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 different table, which I am grabbing in the initial query... I would prefer to do this in the single query, however I supposed I could do a separate loops and grab the number of replies with a totally distinct query SELECT id,title,category,message FROM forum UNION(SELECT count(msg_id) FROM...
1
1768
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 _teamdb_country.name FROM _teamdb, _teamdb_country WHERE _teamdb.country NOT IN (0) AND _teamdb.country = _teamdb_country.id ORDER BY _teamdb_country.name ASC It should look like: France Germany UK But its outputting this: France Germany
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.