Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eliminating zero sum while inserting

Status
Not open for further replies.

hedgracer

Programmer
Mar 21, 2001
186
US
Here is the sql statement:

Insert into BEGACCOUNTINFO (ACCOUNT, ACCOUNTNAME, ENDBAL)
select ACTNUMST,ACTDESCR,SUM(PERDBLNC)
FROM [EQU-SRV-DB].RCG.dbo.Actg_1FR
WHERE PERIODID <= '02'
GROUP BY ACTNUMST, ACTDESCR
ORDER BY 1;

I would like to eliminate any rows wher sum(perdblnc) is 0 while inserting. How would I do that in this statement? Thanks for all help in advance.

Dave
 
Code:
Insert into BEGACCOUNTINFO (ACCOUNT, ACCOUNTNAME, ENDBAL)
select ACTNUMST,ACTDESCR,SUM(PERDBLNC) 
FROM [EQU-SRV-DB].RCG.dbo.Actg_1FR
WHERE PERIODID <= '02'
GROUP BY ACTNUMST, ACTDESCR
[!]Having Sum(PERDBLNC) > 0[/!]
ORDER BY 1;

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I can't do testing. But give it a shot,

Insert into BEGACCOUNTINFO (ACCOUNT, ACCOUNTNAME, ENDBAL)
select ACTNUMST,ACTDESCR,SUM(PERDBLNC)
FROM [EQU-SRV-DB].RCG.dbo.Actg_1FR
WHERE PERIODID <= '02'
GROUP BY ACTNUMST, ACTDESCR having SUM(PERDBLNC) > 0
ORDER BY 1;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top