 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Access 2007 Sql Query</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/</link>
	<description></description>
	<lastBuildDate>Tue, 21 May 2013 15:58:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111295</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Thu, 20 Sep 2012 10:24:14 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111295</guid>
		<description><![CDATA[If that query gives the result you expect and need, I&#039;ll look it over to be sure I understand what it does. Just from impressions, it looks like it can be simplified. Once I&#039;m comfortable that I know its full meaning, simplification should be fairly easy. One question... does mergeddatabase contain one row for each box? -- Tom]]></description>
		<content:encoded><![CDATA[<p>If that query gives the result you expect and need, I&#8217;ll look it over to be sure I understand what it does. Just from impressions, it looks like it can be simplified. Once I&#8217;m comfortable that I know its full meaning, simplification should be fairly easy. One question&#8230; does mergeddatabase contain one row for each box? &#8212; Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: witsendestate</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111293</link>
		<dc:creator>witsendestate</dc:creator>
		<pubDate>Thu, 20 Sep 2012 10:10:17 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111293</guid>
		<description><![CDATA[Sorry to muck up this thread.. Here is the output..]]></description>
		<content:encoded><![CDATA[<p>Sorry to muck up this thread.. Here is the output..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: witsendestate</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111291</link>
		<dc:creator>witsendestate</dc:creator>
		<pubDate>Thu, 20 Sep 2012 10:05:40 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111291</guid>
		<description><![CDATA[SELECT Pickerid, Pickername, ROUND(SUM(totalweight), 2) AS PickersTotalWeight, SUM(totalweight)/ROUND(SUM(pickerhours)) AS HourlyRate, Round(sum(boxcount), 2) AS Boxes, Round(sum(AvgBox), 3) AS AvgBoxWeight
FROM (SELECT pickerid,currentdate,pickerhours,pickername,SUM(currentweight) AS totalweight, count(*) AS BoxCount, avg(currentweight) as AvgBox
FROM mergeddatabase
GROUP BY pickerid,currentdate,pickerhours,pickername)  AS [%$##@_Alias]
WHERE ((currentdate between [Enter first date:] AND [Enter last date:]) and (pickerhours &gt; 0.1))
GROUP BY pickerid, pickername
ORDER BY 4 DESC;
]]></description>
		<content:encoded><![CDATA[<p>SELECT Pickerid, Pickername, ROUND(SUM(totalweight), 2) AS PickersTotalWeight, SUM(totalweight)/ROUND(SUM(pickerhours)) AS HourlyRate, Round(sum(boxcount), 2) AS Boxes, Round(sum(AvgBox), 3) AS AvgBoxWeight<br />
FROM (SELECT pickerid,currentdate,pickerhours,pickername,SUM(currentweight) AS totalweight, count(*) AS BoxCount, avg(currentweight) as AvgBox<br />
FROM mergeddatabase<br />
GROUP BY pickerid,currentdate,pickerhours,pickername)  AS [%$##@_Alias]<br />
WHERE ((currentdate between [Enter first date:] AND [Enter last date:]) and (pickerhours &gt; 0.1))<br />
GROUP BY pickerid, pickername<br />
ORDER BY 4 DESC;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: witsendestate</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111290</link>
		<dc:creator>witsendestate</dc:creator>
		<pubDate>Thu, 20 Sep 2012 10:04:46 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111290</guid>
		<description><![CDATA[Hi Tom,
Once again huge thanks for your help…. 

I tried your suggestion with different variations but had errors.. (Sorry).. Maybe its a Access Sql quirk.

Here is the final Query I came up with which works perfectly..It may not be the ideal coding practices.. I was a Cobol Programmer.. SQL very rusty.

Regards Mark]]></description>
		<content:encoded><![CDATA[<p>Hi Tom,<br />
Once again huge thanks for your help…. </p>
<p>I tried your suggestion with different variations but had errors.. (Sorry).. Maybe its a Access Sql quirk.</p>
<p>Here is the final Query I came up with which works perfectly..It may not be the ideal coding practices.. I was a Cobol Programmer.. SQL very rusty.</p>
<p>Regards Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: witsendestate</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111289</link>
		<dc:creator>witsendestate</dc:creator>
		<pubDate>Thu, 20 Sep 2012 10:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111289</guid>
		<description><![CDATA[Hi Tom,Once again huge thanks for your help.... I tried your suggestion with different variations but had errors.. (Sorry).. Maybe its a Access Sql quirk.Here is the final Query I came up with which works perfectly.. May not be the ideal coding practices.. I was a Cobol Programmer.. SQL very rusty.Also how do you format the text in these posting so its not all wrap around text.Once again thanks Heaps MarkSELECT Pickerid, Pickername, ROUND(SUM(totalweight), 2) AS PickersTotalWeight, SUM(totalweight)/ROUND(SUM(pickerhours)) AS HourlyRate, Round(sum(boxcount), 2) AS Boxes, Round(sum(AvgBox), 3) AS AvgBoxWeightFROM (SELECT pickerid,currentdate,pickerhours,pickername,SUM(currentweight) AS totalweight, count(*) AS BoxCount, avg(currentweight) as AvgBoxFROM mergeddatabaseGROUP BY pickerid,currentdate,pickerhours,pickername)&#160; AS [%$##@_Alias]WHERE ((currentdate between [Enter first date:] AND [Enter last date:]) and (pickerhours &gt; 0.1))GROUP BY pickerid, pickernameORDER BY 4 DESC;]]></description>
		<content:encoded><![CDATA[<p>Hi Tom,Once again huge thanks for your help&#8230;. I tried your suggestion with different variations but had errors.. (Sorry).. Maybe its a Access Sql quirk.Here is the final Query I came up with which works perfectly.. May not be the ideal coding practices.. I was a Cobol Programmer.. SQL very rusty.Also how do you format the text in these posting so its not all wrap around text.Once again thanks Heaps MarkSELECT Pickerid, Pickername, ROUND(SUM(totalweight), 2) AS PickersTotalWeight, SUM(totalweight)/ROUND(SUM(pickerhours)) AS HourlyRate, Round(sum(boxcount), 2) AS Boxes, Round(sum(AvgBox), 3) AS AvgBoxWeightFROM (SELECT pickerid,currentdate,pickerhours,pickername,SUM(currentweight) AS totalweight, count(*) AS BoxCount, avg(currentweight) as AvgBoxFROM mergeddatabaseGROUP BY pickerid,currentdate,pickerhours,pickername)&nbsp; AS [%$##@_Alias]WHERE ((currentdate between [Enter first date:] AND [Enter last date:]) and (pickerhours &gt; 0.1))GROUP BY pickerid, pickernameORDER BY 4 DESC;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: witsendestate</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111203</link>
		<dc:creator>witsendestate</dc:creator>
		<pubDate>Tue, 18 Sep 2012 05:44:32 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111203</guid>
		<description><![CDATA[Hi Tom... Thanks for the valuable input.. I&#039;ll go through your comments now. I appreciate your assistance.RegardsMark]]></description>
		<content:encoded><![CDATA[<p>Hi Tom&#8230; Thanks for the valuable input.. I&#8217;ll go through your comments now. I appreciate your assistance.RegardsMark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111089</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Fri, 14 Sep 2012 05:23:09 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111089</guid>
		<description><![CDATA[Sorry, I put the WHERE clause after the GROUP BY. It really should be befor the GROUP BY. But that&#039;s easy to fix, and Access might not care.
&#160;
Tom]]></description>
		<content:encoded><![CDATA[<p>Sorry, I put the WHERE clause after the GROUP BY. It really should be befor the GROUP BY. But that&#8217;s easy to fix, and Access might not care.<br />
&nbsp;<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111088</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Fri, 14 Sep 2012 05:20:33 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111088</guid>
		<description><![CDATA[Sheesh. Well, anyway...
&#160;
First, I&#039;m no Access expert, so there might be a couple items that work differently than with real SQL. For this part:
&#160;
&lt;BLOCKQUOTE&gt;&lt;CODE&gt;FROM ( SELECT pickerid, currentdate, pickerhours, pickername, SUM(currentweight) AS totalweight FROM mergeddatabase GROUP BY pickerid, currentdate, pickerhours, pickername ) AS [%$##@_Alias] &lt;/CODE&gt;&lt;/BLOCKQUOTE&gt;
&#160;
That&#039;s your table expression for the FROM clause. You have &quot;AS&quot; in order to apply an alias name. I&#039;m just going to call the name MyAlias. So, the basic structure is simply FROM (MyAlias).
&#160;
You have parentheses to mark the beginning and end of that part of your query.
&#160;
The first thing that seems odd to me is that you whole query has a WHERE clause, but the conditions only seem to apply to your table expression. The conditions don&#039;t seem to be totally relevant to your final outer query. To me, it would all seem better if you had things looking like this:
&lt;BLOCKQUOTE&gt;&lt;CODE&gt;FROM ( SELECT pickerid, currentdate, pickerhours, pickername, SUM(currentweight) AS totalweight FROM mergeddatabase GROUP BY pickerid, currentdate, pickerhours, pickername WHERE ((currentdate between [Enter first date:] AND [Enter last date:]) and (pickerhours &gt; 0.1)) ) AS [%$##@_Alias] &lt;/CODE&gt;&lt;/BLOCKQUOTE&gt;
&#160;Hmmm... it&#039;s going to be a mess no matter how I do it.
&#160;
But the WHERE clause is moved up to be part of your table expression instead of being applied to the final query. That is, I moved it inside those parentheses.
&#160;
It&#039;s possible that Access will do that as part of some optimization. It&#039;s also possible that it can&#039;t be done like that because of the parameters for the dates. But it&#039;s the way that it looks like you want things to run.
&#160;
The only place that currentdate is used is inside the table expression. If you only want dates within a range, then they probably should be dropped before putting rows through any summarization and grouping.
&#160;
The&#160;(pickerhours &gt; 0.1) part is questionable, though. Do you want to select&#160;original rows greater than (0.1) or&#160;sums greater than (0.1)? That part might move back to a WHERE clause for the final query.
&#160;
Now, this piece --&#160;ROUND(SUM(pickerhours)) .
&#160;
You have that in your final query. You&#039;re also using pickerhours in the GROUP BY in your table expression, which doesn&#039;t make full sense to me. I can&#039;t see why you want to &quot;group&quot; by that column. I would more expect that to be a SUM() value instead of a GROUP BY. You might have a reason, so I can&#039;t say that it&#039;s wrong. It just seems odd.
&#160;
I looked at your past history. You seem to be coding valid business queries rather than just being a student. I can help with SQL, though Access can be a little different. There are others who can tune whatever we come up with.
&#160;
Look over my comments and see if they are readable and make sense. If we get a solid basic query first, changes will be easier to fix next. Ask questions here if explanations are needed.
&#160;
Tom]]></description>
		<content:encoded><![CDATA[<p>Sheesh. Well, anyway&#8230;<br />
&nbsp;<br />
First, I&#8217;m no Access expert, so there might be a couple items that work differently than with real SQL. For this part:<br />
&nbsp;</p>
<blockquote><p><code>FROM ( SELECT pickerid, currentdate, pickerhours, pickername, SUM(currentweight) AS totalweight FROM mergeddatabase GROUP BY pickerid, currentdate, pickerhours, pickername ) AS [%$##@_Alias] </code></p></blockquote>
<p>&nbsp;<br />
That&#8217;s your table expression for the FROM clause. You have &#8220;AS&#8221; in order to apply an alias name. I&#8217;m just going to call the name MyAlias. So, the basic structure is simply FROM (MyAlias).<br />
&nbsp;<br />
You have parentheses to mark the beginning and end of that part of your query.<br />
&nbsp;<br />
The first thing that seems odd to me is that you whole query has a WHERE clause, but the conditions only seem to apply to your table expression. The conditions don&#8217;t seem to be totally relevant to your final outer query. To me, it would all seem better if you had things looking like this:</p>
<blockquote><p><code>FROM ( SELECT pickerid, currentdate, pickerhours, pickername, SUM(currentweight) AS totalweight FROM mergeddatabase GROUP BY pickerid, currentdate, pickerhours, pickername WHERE ((currentdate between [Enter first date:] AND [Enter last date:]) and (pickerhours &gt; 0.1)) ) AS [%$##@_Alias] </code></p></blockquote>
<p>&nbsp;Hmmm&#8230; it&#8217;s going to be a mess no matter how I do it.<br />
&nbsp;<br />
But the WHERE clause is moved up to be part of your table expression instead of being applied to the final query. That is, I moved it inside those parentheses.<br />
&nbsp;<br />
It&#8217;s possible that Access will do that as part of some optimization. It&#8217;s also possible that it can&#8217;t be done like that because of the parameters for the dates. But it&#8217;s the way that it looks like you want things to run.<br />
&nbsp;<br />
The only place that currentdate is used is inside the table expression. If you only want dates within a range, then they probably should be dropped before putting rows through any summarization and grouping.<br />
&nbsp;<br />
The&nbsp;(pickerhours &gt; 0.1) part is questionable, though. Do you want to select&nbsp;original rows greater than (0.1) or&nbsp;sums greater than (0.1)? That part might move back to a WHERE clause for the final query.<br />
&nbsp;<br />
Now, this piece &#8211;&nbsp;ROUND(SUM(pickerhours)) .<br />
&nbsp;<br />
You have that in your final query. You&#8217;re also using pickerhours in the GROUP BY in your table expression, which doesn&#8217;t make full sense to me. I can&#8217;t see why you want to &#8220;group&#8221; by that column. I would more expect that to be a SUM() value instead of a GROUP BY. You might have a reason, so I can&#8217;t say that it&#8217;s wrong. It just seems odd.<br />
&nbsp;<br />
I looked at your past history. You seem to be coding valid business queries rather than just being a student. I can help with SQL, though Access can be a little different. There are others who can tune whatever we come up with.<br />
&nbsp;<br />
Look over my comments and see if they are readable and make sense. If we get a solid basic query first, changes will be easier to fix next. Ask questions here if explanations are needed.<br />
&nbsp;<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111087</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Fri, 14 Sep 2012 03:52:57 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111087</guid>
		<description><![CDATA[First, I&#039;m going to try to post your original query in a formatted way. Let&#039;s see if it shows up in a readable form:
&#160;SELECT 
    Pickerid, 
    Pickername, 
    ROUND(SUM(totalweight), 2) AS PickersTotalWeight,     SUM(totalweight)/ROUND(SUM(pickerhours)) AS HourlyRate
 FROM (
        SELECT 
            pickerid,
            currentdate,
            pickerhours,
            pickername,
            SUM(currentweight) AS totalweight 
         FROM mergeddatabase 
         GROUP BY 
            pickerid,
            currentdate,
            pickerhours,
            pickername
      ) AS [%$##@_Alias] 
 WHERE ((currentdate between [Enter first date:] AND [Enter last date:]) 
   and (pickerhours &gt; 0.1)) 
 GROUP BY pickerid, pickername;
&#160;If that posts okay, I&#039;ll add some comments. If not, I&#039;ll try it a different way.
&#160;
Tom]]></description>
		<content:encoded><![CDATA[<p>First, I&#8217;m going to try to post your original query in a formatted way. Let&#8217;s see if it shows up in a readable form:<br />
&nbsp;SELECT<br />
    Pickerid,<br />
    Pickername,<br />
    ROUND(SUM(totalweight), 2) AS PickersTotalWeight,     SUM(totalweight)/ROUND(SUM(pickerhours)) AS HourlyRate<br />
 FROM (<br />
        SELECT<br />
            pickerid,<br />
            currentdate,<br />
            pickerhours,<br />
            pickername,<br />
            SUM(currentweight) AS totalweight<br />
         FROM mergeddatabase<br />
         GROUP BY<br />
            pickerid,<br />
            currentdate,<br />
            pickerhours,<br />
            pickername<br />
      ) AS [%$##@_Alias]<br />
 WHERE ((currentdate between [Enter first date:] AND [Enter last date:])<br />
   and (pickerhours &gt; 0.1))<br />
 GROUP BY pickerid, pickername;<br />
&nbsp;If that posts okay, I&#8217;ll add some comments. If not, I&#8217;ll try it a different way.<br />
&nbsp;<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: witsendestate</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111082</link>
		<dc:creator>witsendestate</dc:creator>
		<pubDate>Fri, 14 Sep 2012 02:42:41 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/access-2007-sql-query/#comment-111082</guid>
		<description><![CDATA[If I try and add a SUM &amp; AVG to the query the sum always returns the value of &quot;1&quot; as all the boxes have already been added up to give 1 record.. I want the sum to actually count the boxes for that picker. The Avg is also only averaging the single record not the total of kg&#039;s of the boxes divided by the box count.]]></description>
		<content:encoded><![CDATA[<p>If I try and add a SUM &amp; AVG to the query the sum always returns the value of &#8220;1&#8243; as all the boxes have already been added up to give 1 record.. I want the sum to actually count the boxes for that picker. The Avg is also only averaging the single record not the total of kg&#8217;s of the boxes divided by the box count.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/9 queries in 0.012 seconds using memcached
Object Caching 394/397 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-21 17:25:04 -->