Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 knowing last date

Author  Topic 

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-04-23 : 03:41:33
i have a table in that a column name is modified.date the table name is orderdetails. i want to known the last dates of the column modified.date
just i want the output for each customer orders placed on the customer's last day of activity in every month

my desired out must be like this

custid Modifieddate
----------- -----------------------
1 2008-04-09 00:00:00.000
2 2008-03-04 00:00:00.000
3 2008-01-28 00:00:00.000
4 2008-04-10 00:00:00.000
5 2008-03-04 00:00:00.000
87 2008-04-15 00:00:00.000
88 2008-03-09 00:00:00.000
89 2008-05-01 00:00:00.000
90 2008-04-07 00:00:00.000
91 2008-04-23 00:00:00.000

So please help me



KaShYaP

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-23 : 03:50:35
[code]
select max(MOdifieddate)
from yourtable
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-23 : 04:00:48
shouldnt that be?

select custid,max(MOdifieddate)
from yourtable
group by custid



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-04-23 : 06:28:52
No it gives the max value of the date
but i want the full data that was entered in the last dates of each month only the last entered data in the month ending
please help

KaShYaP
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-04-23 : 06:31:06
[code]
select custid,max(MOdifieddate)
from yourtable
group by custid,Datepart(MM,MOdifieddate)
[/code]

PBUH
Go to Top of Page

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-04-23 : 06:34:36
thanks Mr.Idera it works thanks for considering

KaShYaP
Go to Top of Page
   

- Advertisement -