Duplicate returns to a BAQ

In your query it looks like you are trying to Join JobAsembly to Its Parent but you are only using AssembltSeq as the key, in order to get a Unique Assembly you need to join on Company, JobNum and AssemblySeq


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Wed, Jan 27, 2016 at 12:37 PM, Jose Gomez <jose@...> wrote:
This isn't a BAQ issues as much as a SQL issue. One or more of your joins is causing you to get duplicate data. Most of the time looking at your joins will fix the issue, however there are times where the data is indeed duplicated. In this case you need to add a group by clause or a select distinct to your query.Â


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Wed, Jan 27, 2016 at 11:46 AM, brandonanderson7979@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p>Hi,<br><br>So I am learning how to write BAQ&#39;s and I&#39;m trying to get my first one to work. I apologize if this question has been asked before, but I find this forum extremely hard to find old posts that are relevant. Anyways....<br><br>I am trying to create a pick list for assembly (by job). Below I copied BAQ. The job number for testing is 040017-1-hd, later I&#39;ll figure out how to make that so you type in what job you want.<br><br>The issue that I am having is, I am getting duplicate returns. I get 372 lines, but 189 are duplicates so I should only be receiving 183 lines. It&#39;s looks like it&#39;s always 2 entries when they are duplicated, but it&#39;s not every record. Some come in as expected. Is this a common problem with a common troubleshooting technique? Or is there some group function that I should be using but can&#39;t find, (although I still don&#39;t know why I would receive duplicate returns.)<br><br>Let me know if you need more details. (or more likely, let me know <span style="font-style:italic;">what</span><span> details you need because I&#39;m sure that I am not explaining myself very well.)</span><br></p><p><br></p><p>Brandon<br><span></span></p><p><br><span></span></p><p><span>select <br>Â Â Â  [JobAsmbl].[AssemblySeq] as [JobAsmbl_AssemblySeq],<br>Â Â Â  [JobAsmbl].[PartNum] as [JobAsmbl_PartNum],<br>Â Â Â  [JobAsmbl].[Description] as [JobAsmbl_Description],<br>Â Â Â  [JobAsmbl].[QtyPer] as [JobAsmbl_QtyPer],<br>Â Â Â  [JobAsmbl1second].[PartNum] as [JobAsmbl1second_PartNum],<br>Â Â Â  [JobAsmbl1second].[Description] as [JobAsmbl1second_Description],<br>Â Â Â  [JobAsmbl1second].[QtyPer] as [JobAsmbl1second_QtyPer],<br>Â Â Â  [PartOpDtl].[ResourceGrpID] as [PartOpDtl_ResourceGrpID],<br>Â Â Â  [PartBin].[WarehouseCode] as [PartBin_WarehouseCode],<br>Â Â Â  [PartBin].[BinNum] as [PartBin_BinNum]<br>from Erp.JobAsmbl as JobAsmbl<br>inner join Erp.JobAsmbl as JobAsmbl1second on <br>Â Â Â  JobAsmbl.AssemblySeq = JobAsmbl1second.Parent<br><br>inner join Erp.PartOpDtl as PartOpDtl on <br>Â Â Â  JobAsmbl.PartNum = PartOpDtl.PartNum<br>Â and ( PartOpDtl.ResourceGrpID = &#39;assembly&#39;Â  )<br><br>left outer join Erp.PartBin as PartBin on <br>Â Â Â  JobAsmbl1second.PartNum = PartBin.PartNum<br><br>Â where (JobAsmbl.JobNum = &#39;040017-1-hd&#39;)<br></span></p><p><span><br></span></p><p></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>


Hi,

So I am learning how to write BAQ's and I'm trying to get my first one to work. I apologize if this question has been asked before, but I find this forum extremely hard to find old posts that are relevant. Anyways....

I am trying to create a pick list for assembly (by job). Below I copied BAQ. The job number for testing is 040017-1-hd, later I'll figure out how to make that so you type in what job you want.

The issue that I am having is, I am getting duplicate returns. I get 372 lines, but 189 are duplicates so I should only be receiving 183 lines. It's looks like it's always 2 entries when they are duplicated, but it's not every record. Some come in as expected. Is this a common problem with a common troubleshooting technique? Or is there some group function that I should be using but can't find, (although I still don't know why I would receive duplicate returns.)

Let me know if you need more details. (or more likely, let me know what details you need because I'm sure that I am not explaining myself very well.)


Brandon


select
    [JobAsmbl].[AssemblySeq] as [JobAsmbl_AssemblySeq],
    [JobAsmbl].[PartNum] as [JobAsmbl_PartNum],
    [JobAsmbl].[Description] as [JobAsmbl_Description],
    [JobAsmbl].[QtyPer] as [JobAsmbl_QtyPer],
    [JobAsmbl1second].[PartNum] as [JobAsmbl1second_PartNum],
    [JobAsmbl1second].[Description] as [JobAsmbl1second_Description],
    [JobAsmbl1second].[QtyPer] as [JobAsmbl1second_QtyPer],
    [PartOpDtl].[ResourceGrpID] as [PartOpDtl_ResourceGrpID],
    [PartBin].[WarehouseCode] as [PartBin_WarehouseCode],
    [PartBin].[BinNum] as [PartBin_BinNum]
from Erp.JobAsmbl as JobAsmbl
inner join Erp.JobAsmbl as JobAsmbl1second on
    JobAsmbl.AssemblySeq = JobAsmbl1second.Parent

inner join Erp.PartOpDtl as PartOpDtl on
    JobAsmbl.PartNum = PartOpDtl.PartNum
 and ( PartOpDtl.ResourceGrpID = 'assembly'  )

left outer join Erp.PartBin as PartBin on
    JobAsmbl1second.PartNum = PartBin.PartNum

 where (JobAsmbl.JobNum = '040017-1-hd')


This isn't a BAQ issues as much as a SQL issue. One or more of your joins is causing you to get duplicate data. Most of the time looking at your joins will fix the issue, however there are times where the data is indeed duplicated. In this case you need to add a group by clause or a select distinct to your query.Â


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Wed, Jan 27, 2016 at 11:46 AM, brandonanderson7979@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p>Hi,<br><br>So I am learning how to write BAQ&#39;s and I&#39;m trying to get my first one to work. I apologize if this question has been asked before, but I find this forum extremely hard to find old posts that are relevant. Anyways....<br><br>I am trying to create a pick list for assembly (by job). Below I copied BAQ. The job number for testing is 040017-1-hd, later I&#39;ll figure out how to make that so you type in what job you want.<br><br>The issue that I am having is, I am getting duplicate returns. I get 372 lines, but 189 are duplicates so I should only be receiving 183 lines. It&#39;s looks like it&#39;s always 2 entries when they are duplicated, but it&#39;s not every record. Some come in as expected. Is this a common problem with a common troubleshooting technique? Or is there some group function that I should be using but can&#39;t find, (although I still don&#39;t know why I would receive duplicate returns.)<br><br>Let me know if you need more details. (or more likely, let me know <span style="font-style:italic;">what</span><span> details you need because I&#39;m sure that I am not explaining myself very well.)</span><br></p><p><br></p><p>Brandon<br><span></span></p><p><br><span></span></p><p><span>select <br>Â Â Â  [JobAsmbl].[AssemblySeq] as [JobAsmbl_AssemblySeq],<br>Â Â Â  [JobAsmbl].[PartNum] as [JobAsmbl_PartNum],<br>Â Â Â  [JobAsmbl].[Description] as [JobAsmbl_Description],<br>Â Â Â  [JobAsmbl].[QtyPer] as [JobAsmbl_QtyPer],<br>Â Â Â  [JobAsmbl1second].[PartNum] as [JobAsmbl1second_PartNum],<br>Â Â Â  [JobAsmbl1second].[Description] as [JobAsmbl1second_Description],<br>Â Â Â  [JobAsmbl1second].[QtyPer] as [JobAsmbl1second_QtyPer],<br>Â Â Â  [PartOpDtl].[ResourceGrpID] as [PartOpDtl_ResourceGrpID],<br>Â Â Â  [PartBin].[WarehouseCode] as [PartBin_WarehouseCode],<br>Â Â Â  [PartBin].[BinNum] as [PartBin_BinNum]<br>from Erp.JobAsmbl as JobAsmbl<br>inner join Erp.JobAsmbl as JobAsmbl1second on <br>Â Â Â  JobAsmbl.AssemblySeq = JobAsmbl1second.Parent<br><br>inner join Erp.PartOpDtl as PartOpDtl on <br>Â Â Â  JobAsmbl.PartNum = PartOpDtl.PartNum<br>Â and ( PartOpDtl.ResourceGrpID = &#39;assembly&#39;Â  )<br><br>left outer join Erp.PartBin as PartBin on <br>Â Â Â  JobAsmbl1second.PartNum = PartBin.PartNum<br><br>Â where (JobAsmbl.JobNum = &#39;040017-1-hd&#39;)<br></span></p><p><span><br></span></p><p></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>