Re: SQL Statement for limiting the number of detail retrieved in Access 2000?
- From: Hexman <Hexman@xxxxxxxxxx>
- Date: Mon, 25 Sep 2006 20:44:15 -0700
OK, I understand.
Can anyone give an code example of what Izzy suggests??
Thanks,
Hexman
On 25 Sep 2006 06:03:29 -0700, "Izzy" <israel.richner@xxxxxxxxx> wrote:
Martin is right, this cannot be handled in a query..
This will need to be handled in application code.
The only way this would work in a query is if the only 1 record was
returned by t1.
Izzy
Pritcham wrote:
Hi
I don't think you're going to be able to do this as the "Top x" clause
is going to limit your resultset to x number of records, not x number
of records for each 'grouping' (i.e. the link between your two tables)
so no matter how you try to link the results of this subquery to your
master table, you're only ever (at best) going to get x records from
the subquery.
Cheers
Martin
Hexman wrote:
Izzy,
Thanks for the response. I still can't get it to work, either with Access or SS EE. It generates no error during execution, but doesn't return any
rows. If I take out the "(SELECT TOP 3 t2.* FROM t2)" and change all "t3" references to "t2", it retrieves the rows (except too many of them).
This has me stumped. Any further ideas?
All I want to do is limit the number of rows returned from t2 to be joined with t1.
Thanks,
Hexman
On 23 Sep 2006 16:17:22 -0700, "Izzy" <israel.richner@xxxxxxxxx> wrote:
Try this: (Or something of the like)
SELECT t1.*, t3.*
FROM t1
INNER JOIN
(SELECT TOP 3 t2.*
FROM t2) t3 ON t1.Item = t3.Item
WHERE (t1.TrnDate = #09/23/06#)
You may even want too use a LEFT OUTER JOIN for this, depends on your
data.
Izzy
Hexman wrote:
Hello All,
How do I limit the number of detail records selected in a Master-Detail set using SQL?
I want to select all master records for a date, but only the first 3 records for the details (based on the primary key of the detail record). I've
been trying with "TOP 3", but can't get anywhere. Using Access 2000.
Something like:
SELECT t1.*, TOP 3 t2.*
FROM t1, t2
WHERE (t1.item = t2.item) AND (t1.TrnDate = #09/23/06#)
Any help appreciated,
Hexman
- References:
- SQL Statement for limiting the number of detail retrieved in Access 2000?
- From: Hexman
- Re: SQL Statement for limiting the number of detail retrieved in Access 2000?
- From: Izzy
- Re: SQL Statement for limiting the number of detail retrieved in Access 2000?
- From: Hexman
- Re: SQL Statement for limiting the number of detail retrieved in Access 2000?
- From: Pritcham
- Re: SQL Statement for limiting the number of detail retrieved in Access 2000?
- From: Izzy
- SQL Statement for limiting the number of detail retrieved in Access 2000?
- Prev by Date: Re: Use items from...
- Next by Date: Re: SQL Statement for limiting the number of detail retrieved in Access 2000?
- Previous by thread: Re: SQL Statement for limiting the number of detail retrieved in Access 2000?
- Next by thread: Re: SQL Statement for limiting the number of detail retrieved in Access 2000?
- Index(es):
Relevant Pages
|