Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Duplicate entry

Author  Topic 

srisha
Starting Member

38 Posts

Posted - 2013-05-29 : 05:50:31
select
APIBH.cntbtch, APIBH.cntitem, amttaxdist,amtgrosdst,APIBH.idinvc, APIBH.idvend,dateinvc,textven,
APIBD.textdesc,amtdistnet,billdate,amtdisthc,
glamf.acctfmttd,acctdesc,
--(select amtadjtot from APTCP where BATCHTYPE='AD')
aptcp.AMTADJTOT, BATCHTYPE

from APIBH
inner join APIBD on APIBH .cntbtch= APIBD .cntbtch And APIBH.cntitem=APIBD.cntitem
inner join glamf on APIBD .idglacct= glamf.acctfmttd
inner join aptcp on APIBH.idinvc=aptcp .idinvc and apibh.idvend =aptcp .idvend

where APIBD.cntbtch=3
and APIBD.cntitem >= 1 and APIBD.cntitem <= 1
order by APIBD.cntbtch

srisha
Starting Member

38 Posts

Posted - 2013-05-29 : 05:51:48
avoid the duplicate entry
Help me
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-29 : 05:52:50
what is the problem here?
(select amtadjtot from APTCP where BATCHTYPE='AD') --> may be returning more than one row with duplicates?

select DISTINCT amtadjtot from APTCP where BATCHTYPE='AD'


--
Chandu
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-29 : 05:55:23
What is the purpose of this condition ?
(and APIBD.cntitem >= 1 and APIBD.cntitem <= 1 ) --> this condition true only for APIBD.cntitem = 1


--
Chandu
Go to Top of Page

srisha
Starting Member

38 Posts

Posted - 2013-05-29 : 07:30:22
this is From and to
Go to Top of Page

srisha
Starting Member

38 Posts

Posted - 2013-05-29 : 07:32:44
select
APIBH.cntbtch, APIBH.cntitem, amttaxdist,amtgrosdst,APIBH.idinvc, APIBH.idvend,dateinvc,textven,
APIBD.textdesc,amtdistnet,billdate,amtdisthc,
glamf.acctfmttd,acctdesc,
aptcp.amtadjtot, BATCHTYPE

from APIBH
inner join APIBD on APIBH .cntbtch= APIBD .cntbtch And APIBH.cntitem=APIBD.cntitem
inner join glamf on APIBD .idglacct= glamf.acctfmttd
inner join aptcp on APIBH.idinvc=aptcp .idinvc and apibh.idvend =aptcp .idvend

where APIBD.cntbtch={?Batch Number}
and APIBD.cntitem >= {?Entry Number From} and APIBD.cntitem <= {?Entry Number To}
order by APIBD.cntbtch
same problem duplict entrys
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-05-29 : 07:54:54
Replace the "SELECT" key word with "SELECT Distinct", which will make sure every row to be unique.

However, still if you feels that there is duplication then provide (just a couple of instances of) the duplicate data generated as a result of this query? And explain what makes you think them to be duplicate?

Cheers
MIK
Go to Top of Page
   

- Advertisement -