Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Top 1 in Query

Status
Not open for further replies.

Halliarse

IS-IT--Management
Jan 8, 2007
213
GB
Hi

I need help!!

I have 2 tables, tblCountries and tblTempSubscriptions
tblTempsubscriptions has a column CountryConv and is linked to tblTempSubscriptions by the field Country NR. The tblCountries may have multiple records that contain the same CountryConv and I want to only pick up the 1st occurence, possibly using TOP 1, sorting the tblCountries by ascending Country NR but I'm unable to get the query to do this....any ideas please?

I hope that makes sense!!

Thanks

Steve

 
I would probably use a totals query [qgrpMaxCountryNR] that

SQL:
SELECT CountryConv, Min([Country NR]) as MaxCountryNR FROM tblCountries GROUP BY CountryConv

Then create a query that joins with qgrpMaxCountryNR using CountryConv and MaxCountryNR.

If you need to edit the results, you will probably need to use a subquery and identify the primary key field in tblCountries.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top