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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL (Rollup and Having)!

Status
Not open for further replies.

CW1

Programmer
Apr 11, 2000
8
0
0
DE
Hello!<br>Who can help me?<br>Sorry but my english is not so good. I have a small problem.<br>My Select:<br>&quot;Select Fb, SUM(Wert) as Wert WHERE ... GROUP BY Fb WITH ROLLUP HAVING SUM(Wert) between 100000 and 200000 ORDER BY Fb&quot;<br>Result:<br>001 100012<br>003 199999 ....<br><br>Without ROLLUP I become a record with&nbsp;&nbsp;NULL and a SUM.<br>What can I do, that i become the NULL - Value from the ROLLUP function. I need a SUM about all the resultrecord's.<br>Thank's<br><br>
 
Why do you want to sum nulls, they have no value to sum? <p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>
 
Sorry but by description was not so good!<br>I will not sum nulls. I think my problem cannot work with HAVING and ROLLUP because HAVING exclude the Group - Sums.<br>Two example's:<br>1. Select Fb, Sum(Wert) WHERE... Group By Fb with Rollup<br>Result: 001&nbsp;&nbsp;100.000<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;002&nbsp;&nbsp;150.000<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NULL 200.000<br>2. Select Fb, Sum(Wert) WHERE... Group By Fb with Rollup&nbsp;&nbsp;HAVING SUM (Wert) between 120.000 and 170.000<br>Result: 002&nbsp;&nbsp;150.000<br><br>I think, that the function ROLLUP execute after the function Having. But this is not correct. <br><br>I need the result:<br>002&nbsp;&nbsp;150.000<br>NULL 150.000<br>The select must be always the same.<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top