|
-
Sep 7th, 2006, 06:35 PM
#1
Thread Starter
Lively Member
(Solved) Duplicated Records On Query...
Hi everybody... I have loooking for some answers to my problem in the forum but I got nothing... so here I am....
Lets say that Table A has the following fields: Order,Rack, ID, INDate, EndDate.
And TableB has: Order, Model, Line, CaptDate, Qty.
Here is my query for a lis of racks used by Line:
VB Code:
SQL = "SELECT Rack, Sum(1) as TotalRack FROM TableA " _
& ", TableB WHERE TableA .Orden = TableB.Orden" _
& " AND TableB.Linea = '" Line "' GROUP BY Rack ORDER BY TotalRack DESC"
I found that I got repeated records if Orden is repeated in TableB, so the question is how can I get rid of those duplicated records?... I mean that if there is a match and TableA.Orden exist in TableB then it counts (thats OK) but if TableA.Orden exist twice then it counts twice (thats not good)...
Hope you can help me...
Last edited by G-Hawk; Sep 9th, 2006 at 05:12 PM.
Reason: Change of Title (Resolved)
-
Sep 9th, 2006, 02:41 PM
#2
Thread Starter
Lively Member
Re: Duplicated Records On Query...
Change the Question because I found the reason why I'm getting extra count data, still I don't know how to fixed...
-
Sep 9th, 2006, 05:10 PM
#3
Thread Starter
Lively Member
Re: Duplicated Records On Query...
Well... in the end I found out how to avoid duplicated values (I saw some light because of a previous question answered by Si_The_Geek related to a similiar problem)
VB Code:
SQL = "SELECT Rack, Count(Rack) as TotalRack FROM TableA" _
& ",(SELECT DISTINCT TableB.Orden, Linea FROM TableB) as NTB WHERE TableA.Orden = NTB .Orden " _
& " AND NTB .Linea = '" & CombOp2.List(CombOp2.ListIndex) & "' " _
& " GROUP BY Rack ORDER BY TotalRack DESC"
The problem was due to duplicated TableA.Orden in TableB so I just wanted to have non duplicated records on TableB and I came up with the solution... ...
Hope can be useful for someone..
C-ya!
Last edited by G-Hawk; Sep 9th, 2006 at 05:11 PM.
Reason: Include VBCode separators
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
|
Click Here to Expand Forum to Full Width
|