https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/101256&feed=atom&action=historyMicrosoft KB Archive/101256 - Revision history2024-03-28T11:29:04ZRevision history for this page on the wikiMediaWiki 1.39.3https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/101256&diff=431121&oldid=prevX010: X010 moved page Microsoft KB Archive/Q101256 to Microsoft KB Archive/101256 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/"2020-08-12T18:13:14Z<p>X010 moved page <a href="/wiki/index.php?title=Microsoft_KB_Archive/Q101256&action=edit&redlink=1" class="new" title="Microsoft KB Archive/Q101256 (page does not exist)">Microsoft KB Archive/Q101256</a> to <a href="/wiki/index.php?title=Microsoft_KB_Archive/101256" title="Microsoft KB Archive/101256">Microsoft KB Archive/101256</a> without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/"</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<tr class="diff-title" lang="en-GB">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 18:13, 12 August 2020</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en-GB"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>X010https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/101256&diff=236840&oldid=prev3155ffGd: importing KB archive2020-07-18T17:49:42Z<p>importing KB archive</p>
<p><b>New page</b></p><div>BUG: Incorrect Result When Multiple Aggregate Functions in SQL PSS ID Number: Q101256 Article last modified on 02-09-1994<br />
<br />
3.00<br />
<br />
WINDOWS<br />
<br />
{|<br />
|width="97%"| The information in this article applies to:<br />
|-<br />
| - Standard and Professional Editions of Microsoft Visual Basic for Windows, version 3.0<br />
|}<br />
<br />
= SYMPTOMS =<br />
<br />
When an SQL query statement contains multiple aggregate functions, the result incorrectly shows the same value for all the functions. The result of the first aggregate function is duplicated in the result column of all of the other functions.<br />
<br />
= CAUSE =<br />
<br />
Aggregate functions typically do not contain explicit column names for expressions in the SQL query. In SQL queries containing multiple aggregate function calls, the Access database layer does not uniquely identify the return columns for any functions past the first. Therefore, it duplicates the result column of the first function in the result columns of the succeeding functions<br />
<br />
This problem did not occur in Visual Basic version 2.0. In Visual Basic version 3.0, the Microsoft Access engine was integrated into the data access functionality. The Microsoft Access engine tracks the column by name, whereas Visual Basic version 2.0 tracks the column by the column offset.<br />
<br />
= WORKAROUND =<br />
<br />
Use aliases for the aggregate functions to solve the problem. Replace the SQL statement shown below in the “Steps to Reproduce Problem” section with the following SQL statement, which contains the aliases One and Two for the column names for the separate SUM expressions:<br />
<br />
Select SUM(PubID) as One, SUM(Au_ID) as Two From Titles<br />
<br />
The Alias names can be anything other than the column name and must be unique within the statement.<br />
<br />
After inserting the aliases, run the SQL statement again and notice that the two fields now correctly show the different results.<br />
<br />
= STATUS =<br />
<br />
Microsoft has confirmed this to be a bug in the products listed above. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.<br />
<br />
= MORE INFORMATION =<br />
<br />
== Steps to Reproduce Problem ==<br />
<br />
<ol style="list-style-type: decimal;"><br />
<li><p>Start Visual Basic.</p></li><br />
<li><p>From the File menu, choose Open Project (ALT, F, O). Open VISDATA.MAK from the VBdirectory.</p></li><br />
<li><p>From the Run menu, choose start (ALT, R, S) or press F5 to run the program.</p></li><br />
<li><p>From the Visual Data File menu, choose OpenDatabase. From the sub menu choose MS Access.</p></li><br />
<li><p>From the Open MS Access Database dialog box, select the BIBLIO.MDB file.</p></li><br />
<li><p>For the Recordset Form Type, select Grid.</p></li><br />
<li><p>Enter the following SQL statement in the SQL Statement window:</p><br />
<p>Select SUM(PubID), SUM(Au_ID) From Titles</p></li><br />
<li><p>Click the Execute SQL command Button.</p></li><br />
<li><p>The result shows in a grid window. The two fields have the same value. They should be different.</p></li></ol><br />
<br />
Additional reference words: 3.00 KBCategory: KBSubcategory: APrgDataIISAM<br />
<br />
=============================================================================<br />
<br />
Copyright Microsoft Corporation 1994.</div>3155ffGd