<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : group by and having clauses</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : group by and having clauses</description>
  <pubDate>Mon, 13 Apr 2026 14:20:40 -700</pubDate>
  <lastBuildDate>Sun, 07 Jul 2013 18:28:29 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=4214</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>group by and having clauses : If duesOwed contains items of...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4214&amp;PID=16551#16551</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 4214<br /><strong>Posted:</strong> 07-Jul-2013 at 6:28pm<br /><br />If duesOwed contains items of type MemberDuesRecord, then "groups" here will be an IEnumerable&lt;IGrouping&lt;, MemberDuesRecord&gt;&gt;.  If you hover over the groups variable, Visual Studio Intellisense will tell you what the type is.<br /><br />You can do something like this to apply the having and order by clauses:<br /><br />groups<br /> .Where(g =&gt; g.Sum(d =&gt; d.DuesAmount) &gt; 0)<br /> .OrderByDescending(g =&gt; g.Key)<br /><br />I'm not quite sure what you want to return, but since an IGrouping is hard to work with it might be easier to project the results into an anonymous type.<br /><br />This is standard <a href="http://msdn.microsoft.com/en-us/library/bb344977%28v=vs.100%29.aspx" target="_blank">LINQ</a>, so a web search may produce more clever answers.<br /><br /><br />]]>
   </description>
   <pubDate>Sun, 07 Jul 2013 18:28:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4214&amp;PID=16551#16551</guid>
  </item> 
  <item>
   <title>group by and having clauses : i have an IEnumerable which was...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4214&amp;PID=16549#16549</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 4214<br /><strong>Posted:</strong> 07-Jul-2013 at 5:54am<br /><br />i have an IEnumerable which was created by a query of a table. It contains all the dues records for a particular member. <DIV></DIV><DIV>&nbsp;</DIV><DIV>duesOwed</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV>i need to filter it as follows. I want to group the data by DuesYeaMonth. Thats just a string column in the format 20130701</DIV><DIV>Year/Month/Day. I only want the rows where the Dues Category code (DuesCatCd) starts with "D" and after they are grouped only those groups where DuesAmount &lt;&gt; 0 and ordered by DuesYearMonth in descending order. So basically i am trying to find the newest dues record still owing and will work my way back to the first.</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV>here is what i have so far. I figure it has to be done in two statements.</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV>var groups = duesOwed.Where(d =&gt; d.DuesCatCd.StartsWith("D")).GroupBy(d =&gt; d.DuesYearMonth);</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV>now the part i am not sure about</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV>var MostRecordDuesRecord = groups.Where(d =&gt; d.DuesAmount != 0).OrderByDescending(d =&gt; d.DuesYearMonth);</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV>What is groups though. Visual Studio doesnt seem to think it&nbsp;is a IEnumerable of&nbsp;DuesOwed records&nbsp;because DuesAmount is in red and it doesnt like the parameter to OrderByAscending.</DIV>]]>
   </description>
   <pubDate>Sun, 07 Jul 2013 05:54:00 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4214&amp;PID=16549#16549</guid>
  </item> 
 </channel>
</rss>