﻿<?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 / SQL Server 2008 - General  / how to find max amount / 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, 25 May 2013 05:30:21 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>Same result as TakeITeasy, but using a derived table.SELECT	* FROM	(			SELECT ROW_NUMBER() OVER (PARTITION BY id ORDER BY adate desc) AS ROW, 			id,			amount, 			adate 			FROM @t 		) TWHERE T.ROW = 1</description><pubDate>Fri, 27 Aug 2010 11:44:09 GMT</pubDate><dc:creator>caladba</dc:creator></item><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>Hi, Change @t to your table name and your columns for id, amount, adate WITH cte AS ( SELECT ROW_NUMBER() OVER (PARTITION BY id ORDER BY adate desc) AS ROW, id,amount, adate FROM @t ) SELECT *FROM ctewhere Row = 1this should work fine.</description><pubDate>Fri, 27 Aug 2010 10:52:05 GMT</pubDate><dc:creator>TakeITeasy</dc:creator></item><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>Hi ,Try this scriptDeclare @t table(id int, amount varchar(10),adate datetime)insert into @t select 1,'120', dateadd(day,-1,getdate())insert into @t select 2,'121', getdate()insert into @t select 1,'122', dateadd(day,-2,getdate())insert into @t select 4,'123', getdate()insert into @t select 1,'124', getdate()insert into @t select 3,'125', dateadd(day,-3,getdate())insert into @t select 3,'126', getdate()--------HERE ;WITH cte AS ( SELECT ROW_NUMBER() OVER (PARTITION BY id ORDER BY adate desc) AS ROW, id,amount, adate FROM @t ) SELECT *FROM ctewhere Row = 1Thanks,</description><pubDate>Fri, 27 Aug 2010 10:39:44 GMT</pubDate><dc:creator>TakeITeasy</dc:creator></item><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>You can use ROW_NUMBER() with PARTITION clause.[url=http://msdn.microsoft.com/en-us/library/ms186734.aspx]http://msdn.microsoft.com/en-us/library/ms186734.aspx[/url]</description><pubDate>Thu, 26 Aug 2010 10:23:29 GMT</pubDate><dc:creator>caladba</dc:creator></item><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>SELECT  EMPNAME,	AMOUNT,		RECIVEDDATEFROM    Table_Name AWHERE   RECIVEDDATE =  (SELECT MAX(Reciveddate) FROM Table_Name B WHERE A.RecivedDate = B.RecivedDate)Plz let me knw, whther this query solved your problem</description><pubDate>Wed, 25 Aug 2010 23:37:40 GMT</pubDate><dc:creator>Subbu S</dc:creator></item><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>[quote][b]varshini (8/19/2010)[/b][hr]can you expline me how to use the simple query to achive this ?[/quote]If people start giving you the solutions directly you will not learn. Wayne has given you the correct suggestion. Try some code yourself and if you are stuck somewhere, get back to us with the code that you have tried. We will be more than happy to help you.</description><pubDate>Thu, 19 Aug 2010 06:54:09 GMT</pubDate><dc:creator>Kingston Dhasian</dc:creator></item><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>Hi,SELECT Employeeid,max(Amount),receiveddate from tablegroup by Employeeid,receiveddate.:-)Varun Rhttp://www.sqlinfo.in</description><pubDate>Thu, 19 Aug 2010 02:09:50 GMT</pubDate><dc:creator>varunfilim</dc:creator></item><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>can you expline me how to use the simple query to achive this ?</description><pubDate>Thu, 19 Aug 2010 02:02:19 GMT</pubDate><dc:creator>varshini</dc:creator></item><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>I would suggest:1. Using a Common Table Expression (CTE), get all the values of the table. Utilize the row_number function to assign row numbers to each row, starting at one for each employeeid, and ordering by the date descending, putting this value into a new column (RN).2. Select the columns from the CTE where the new column RN = 1.For assistance in figuring out how to use the row_number function, see [url=http://www.sqlservercentral.com/articles/T-SQL/69717/][u]this article[/u][/url].</description><pubDate>Wed, 18 Aug 2010 21:46:26 GMT</pubDate><dc:creator>WayneS</dc:creator></item><item><title>RE: how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>use a max() aggregate and a group by clause.It's fairly simple, but it almost seems like this is homework. Try it yourself.</description><pubDate>Wed, 18 Aug 2010 21:41:40 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>how to find max amount</title><link>http://www.sqlservercentral.com/Forums/Topic971575-391-1.aspx</link><description>i have the following tableEmployeeid    Amount       ReceivedDate1                  3000          2010-Jan-191                  4000          2009-Dec-101                  2500          2009-Mar-2519                3400          2010-Apr-2519                8700          2010-Jan-1027                7700          2009-May-2927                3400          2006-Jul-20i need the following output from above table(employee amount for max receivedDate)Employeeid    Amount       ReceivedDate1                  3000          2010-Jan-1919                3400           2010-Apr-2527                7700           2009-May-29how to achive this ?</description><pubDate>Wed, 18 Aug 2010 21:13:21 GMT</pubDate><dc:creator>varshini</dc:creator></item></channel></rss>