Subquery SQL help!

Pienuts

Registered User.
Local time
Yesterday, 23:02
Joined
May 2, 2014
Messages
106
Hi, all - I have a one-to-many query which I would like to add a subquery to eliminate all but the TOP 1 of a field.

Here is the SQL:

Code:
SELECT QrySitesBatteries.SiteKey, QrySitesBatteries.SITEID, QrySitesBatteries.Battery
FROM QrySitesBatteries
WHERE (((QrySitesBatteries.Battery)=[Forms]![FMHome]![Battery])) OR ((([Forms]![FMHome]![Battery]) Is Null))
ORDER BY QrySitesBatteries.SITEID;

And I would like to only show the TOP 1 of the SiteKey field. I have been googling my fingers off but SQL hurts my head!:confused:

So, I think I have to add the subquery before the ORDER BY, but can't quite wrap my head around it.

Any assistance would be appreciated; thanks!
 
It's not making any sense to me. Can you upload some fictitious data showing what you currently have and what you would like it to be. Put this in a spreadsheet.
 
Thanks, I had been on that site for a few hours yesterday but I couldn't quite figure out how to translate it to my needs.
I have solved my current issue by just changing the query to a totals (first) query and it does what I need, so I will remain in subquery ignorance for the time being.
Thanks for trying!
 

Users who are viewing this thread

Back
Top Bottom