-
2 Selects ---> 1 Self Join
Hi, I asked this in ACCESS section but here says ask an expert...
if its a duplicate post please delete it(here is more explained) otherwise here is my question:
Before going further whats better 2 Selects in a query or 1 Self Join (In terms of efficiency)?
If its better 1 self join rather than 2 Selects... here we go:
Database: Access 2000
If i have a table like this:
SN VN GV LD LV (Ignore "..")
a..a1..a2..1..0
a..a2..a3..2..0
X.. Y.. Z ..1..2
X.. Y.. Z ..2..2
x.. b.. c ..1..2
b.. b.. b ..2..2
---------------
Conditions: SN = 'X' AND VN = 'Y' AND GV= 'Z' AND MIN(LD)
My query should show just this: (I dont need to select LV)
SN VN GV LD
X Y Z 1
Right now my query shows:
SN VN GV LD
X Y Z 1
So it works fine. But im looking to be more efficient thats why i thought in a Self join.
This is my query:
SELECT l.SN, l.VN, l.GN, l.LD
FROM l
WHERE (((l.SN)='X') AND ((l.VN)='Y') AND ((l.GN)='Z') AND ((l.LD)<=(Select MIN(l2.LD) from l l2 where ((l2.SN)='X') AND ((l2.VN)='Y') AND ((l2.GN)='Z') )));
I tried to do the self join of this query but didnt do it right :/
So any advice/help will be appreciated.
Thanks in advance
Regards.
Last edited by markhan; 03-10-2011 at 04:01 AM.
-
FIXED, i dont need the answer... i found the solution was quite simple :/ just with one select and some group by fixed the problem.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|