﻿<?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 2005 / SQL Server Newbies  / amount difference between 2 dats / 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>Wed, 22 May 2013 12:56:51 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>Thanks Gila</description><pubDate>Sun, 14 Sep 2008 00:34:28 GMT</pubDate><dc:creator>mathewspsimon</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>Does this work?[code]-- first, some setup.CREATE TABLE #Amounts ( SomeDate DATETIME, SomeAmount INT)insert into #Amounts values ('2008/09/01',500)insert into #Amounts values ('2008/09/02',1500)insert into #Amounts values ('2008/09/03',3500)-- Setup finishedCREATE TABLE #WorkTable (	RowID INT IDENTITY PRIMARY KEY,	SomeDate DATETIME,	SomeAmount INT)INSERT INTO #WorkTable (SomeDate, SomeAmount)SELECT SomeDate, SomeAmount	FROM #Amounts	ORDER BY SomeDate	SELECT CurrentDay.SomeDate, CurrentDay.SomeAmount-PreviousDay.SomeAmount from #WorkTable PreviousDay inner join #WorkTable CurrentDay	on PreviousDay.RowID = CurrentDay.RowID - 1[/code]</description><pubDate>Thu, 11 Sep 2008 09:45:38 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>no chance for duplicates</description><pubDate>Thu, 11 Sep 2008 06:25:45 GMT</pubDate><dc:creator>mathewspsimon</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>Any chance of duplicate dates?</description><pubDate>Thu, 11 Sep 2008 06:12:14 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>Hi,Yes,dates can miss and it is not consecutive.Also dates are all midnight.</description><pubDate>Thu, 11 Sep 2008 05:20:16 GMT</pubDate><dc:creator>mathewspsimon</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>Please post SQL 2000 questions in the SQL 2000 forums in the future. Posting in the 2005 forums means that people will give you 2005-specific solutions.Are the dates always consecutive? Is it possible for there ever to be a date missing? Do the dates have various times associated with them, or is the time always set to midnight?</description><pubDate>Thu, 11 Sep 2008 05:15:54 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>this is 2000 and its not homework.the first table is a sales table which gets updated w when a sale happnes.to arrive at the sale for a specific date I have to get the difference from previous date.also these were created,triggers wrote before.i will not be able to modifiy them</description><pubDate>Thu, 11 Sep 2008 04:50:31 GMT</pubDate><dc:creator>mathewspsimon</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>2000 or 2005?What happens if a date is missing?Is it homework?</description><pubDate>Thu, 11 Sep 2008 04:45:47 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>[quote][b]mathewspsimon (9/11/2008)[/b][hr]no PK and Indexes are there.[/quote]That pretty much identifies this as a homework question. Rather than solve this for you, here's an article which discusses more than one method for dealing with this type of problem, and the relative merits and drawbacks of each. Read the article, try one or two of the methods, and if you're still unsure, then repost. Good luck![url]http://www.sqlservercentral.com/articles/Advanced+Querying/61716/[/url]CheersChrisM</description><pubDate>Thu, 11 Sep 2008 04:38:11 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>no PK and Indexes are there.</description><pubDate>Thu, 11 Sep 2008 04:32:39 GMT</pubDate><dc:creator>mathewspsimon</dc:creator></item><item><title>RE: amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>Hi MathewWhat do you have in the way of pk / indexes in this table?CheersChrisM</description><pubDate>Thu, 11 Sep 2008 04:29:16 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>amount difference between 2 dats</title><link>http://www.sqlservercentral.com/Forums/Topic567580-1291-1.aspx</link><description>Hi All,I have a table like thisDate                    Amount09/01/2008            50009/02/2008           150009/03/2008           3500I want a output which is as follows -Date               Amount09/02/2008      100009/03/2008      2000where the amount column is the diference from the previous date so in this example 2nd sept amount is the difference bet 2nd and 1st sept  so also for 3rd sept amount.Can some help to write a query for this.</description><pubDate>Thu, 11 Sep 2008 04:16:51 GMT</pubDate><dc:creator>mathewspsimon</dc:creator></item></channel></rss>