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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Max date Help

Author  Topic 

nhaas
Yak Posting Veteran

90 Posts

Posted - 2012-06-04 : 13:00:44
I am haning issues with MAX dax

I have a table which is Name, dept, date1,aduser

I can run "Select name,Max(date1) From Table group by name". but I want to see the dept also how can I run this. everytime I run this I dont get the Max date.

How can I run "Select Name, dept,MAX(date1) group by name"

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-04 : 13:08:22
[code]
select t.*
from Table t
INNER JOIN (Select name,Max(date1) as maxdate
From Table
group by name
)t1
on t1.name = t.name
and t1.maxdate = t.date1
[/code]

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

Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2012-06-04 : 13:33:28
Thank you visakh16!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-04 : 14:54:39
welcome

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

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-06-05 : 05:21:46
or

select * from table as t1
where date1=(Select Max(date1) From Table as t2 where t1.name=t2.name)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -