﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Help with Count over days (but not per day) ... the total up until that day through the date range. / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 11:11:32 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Help with Count over days (but not per day) ... the total up until that day through the date range.</title><link>http://www.sqlservercentral.com/Forums/Topic1366254-392-1.aspx</link><description>Great thanks... now that I understand what I am looking for (the running total part), I see that there is a bunch of information out there.Thanks again.</description><pubDate>Mon, 01 Oct 2012 09:15:23 GMT</pubDate><dc:creator>Kevlarmpowered</dc:creator></item><item><title>RE: Help with Count over days (but not per day) ... the total up until that day through the date range.</title><link>http://www.sqlservercentral.com/Forums/Topic1366254-392-1.aspx</link><description>[quote][b]diamondgm (10/1/2012)[/b][hr][quote]I believe Jeff talks about this "triangular join" in the article I referenced.[/quote]I don't think that its a triangular join - no subquery really.It looks like a moficifation of the CROSS JOIN method of running total computation.Instead of a filtered CROSS JOIN, the INNER JOIN condition is expanded.This is something that Jeff did not cover in his article as far as I can remember.This is my understanding; I'm open to correction.[/quote]You're correct.  It's not a "triagular join".  It's worse.  It's a full accidental cross join.  Look at the execution plan.  You have 5 rows of data but one of the arrows coming off the table has 25 rows.  If you add one more row to the data, that arrow jumps to 36, as expected with a cross join.</description><pubDate>Mon, 01 Oct 2012 06:54:28 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Help with Count over days (but not per day) ... the total up until that day through the date range.</title><link>http://www.sqlservercentral.com/Forums/Topic1366254-392-1.aspx</link><description>[quote]I believe Jeff talks about this "triangular join" in the article I referenced.[/quote]I don't think that its a triangular join - no subquery really.It looks like a moficifation of the CROSS JOIN method of running total computation.Instead of a filtered CROSS JOIN, the INNER JOIN condition is expanded.This is something that Jeff did not cover in his article as far as I can remember.This is my understanding; I'm open to correction.</description><pubDate>Mon, 01 Oct 2012 06:37:01 GMT</pubDate><dc:creator>diamondgm</dc:creator></item><item><title>RE: Help with Count over days (but not per day) ... the total up until that day through the date range.</title><link>http://www.sqlservercentral.com/Forums/Topic1366254-392-1.aspx</link><description>[quote][b]Sony Francis @EY (10/1/2012)[/b][hr]May be this query will help your problemCREATE TABLE #Temp (Name varchar(100), value int)INSERT INTO #Temp SELECT 'Day1',  12UNION SELECT 'Day2'  ,6UNIONSELECT 'Day3' , 10UNION SELECT 'Day4' ,8UNIONSELECT 'Day5' ,4;with cte as(select *, ROW_NUMBER() over(PARTITION by null order by Name ) as IdFROM #Temp ) SELECT b.Name , SUM(A.value ), B.Id FROM cte AINNER JOIN cte B on A.Id &amp;lt;= B.Id GROUP BY B.Name ,  b.id[/quote]I believe Jeff talks about this "triangular join" in the article I referenced.</description><pubDate>Mon, 01 Oct 2012 02:52:37 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Help with Count over days (but not per day) ... the total up until that day through the date range.</title><link>http://www.sqlservercentral.com/Forums/Topic1366254-392-1.aspx</link><description>May be this query will help your problemCREATE TABLE #Temp (Name varchar(100), value int)INSERT INTO #Temp SELECT 'Day1',  12UNION SELECT 'Day2'  ,6UNIONSELECT 'Day3' , 10UNION SELECT 'Day4' ,8UNIONSELECT 'Day5' ,4;with cte as(select *, ROW_NUMBER() over(PARTITION by null order by Name ) as IdFROM #Temp ) SELECT b.Name , SUM(A.value ), B.Id FROM cte AINNER JOIN cte B on A.Id &amp;lt;= B.Id GROUP BY B.Name ,  b.id</description><pubDate>Mon, 01 Oct 2012 02:48:44 GMT</pubDate><dc:creator>Sony Francis @EY</dc:creator></item><item><title>RE: Help with Count over days (but not per day) ... the total up until that day through the date range.</title><link>http://www.sqlservercentral.com/Forums/Topic1366254-392-1.aspx</link><description>This article by Jeff Moden gives you arguably the best way to approach the running totals problem:[url]http://www.sqlservercentral.com/articles/T-SQL/68467/[/url]</description><pubDate>Sun, 30 Sep 2012 23:51:55 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>Help with Count over days (but not per day) ... the total up until that day through the date range.</title><link>http://www.sqlservercentral.com/Forums/Topic1366254-392-1.aspx</link><description>I am having an issue trying to wrap my head around this.I am trying to get the count of something over the days in a date range, but I don't need a per day count, I need the count of items for each day through the date range... does that make sense?For example... the output should look something like this.Day1 - 12Day2 - 18Day3 - 24Day4 - 32Day5 - 80So, on Day1, there were 12 items.  On Day2 there were 6 additional, so 12+6.  On Day3 there were 6, so 12+6+6, Day4 there were 8, so 12+6+6+8, Day5 there were 48, so 12+6+6+8+48.I am sure there is a way, but I can't wrap my head around it.</description><pubDate>Sun, 30 Sep 2012 08:06:57 GMT</pubDate><dc:creator>Kevlarmpowered</dc:creator></item></channel></rss>