C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




SQL Query - Max of date


Posted Date: 22 Nov 2008      Total Responses: 4

Posted By: saravanakumar       Member Level: Silver     Points: 1



hi,

My table consist of following,

11/19/2008 5000
11/23/2008 10000
11/24/2008 12000
12/01/2008 15000
12/15/2008 20000

Here i have to fetch the row which have 12000 and 20000 [Max date in each month].





Responses

Author: Sankar Venkat    23 Nov 2008Member Level: SilverRating:     Points: 3

Saravanan,
This will solve your problem.

SELECT MAX(Date) FROM contact
group by CONVERT(VARCHAR(7),Date, 120)


For more details about date format refer
http://www.sql-server-helper.com/tips/date-formats.aspx



Author: Sriman N Vangala    23 Nov 2008Member Level: DiamondRating:     Points: 3

Assuming that your requirement is to display the put put like this:

Month MaxAmt
11 12000
12 20000

select month(datecolumn) , max(amt) from Tablename
group by month(datecolumn)




Post Reply
You must Sign In to post a response.
Next : @@NESTLEVEL
Previous : Find Last Modified Row In Sql TAble
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use