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.
| Author |
Topic |
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2009-10-07 : 05:48:42
|
| I have a table with structurediary-----clientid date code-------- ---- ----10122 2009-04-03 3How can I return the clientid where the max date is greater than 6 months from today's date please? |
|
|
sanoj_av
Posting Yak Master
118 Posts |
Posted - 2009-10-07 : 05:55:29
|
| Select clientidgroup by clientidhaving max(date) > dateadd(M,6,getdate()) |
 |
|
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2009-10-07 : 06:19:11
|
Thanks for the reply.I made an error. I should have asked'How can I return the clientid where the max date is older than 6 months prior to today's date please?'My apologies |
 |
|
|
sanoj_av
Posting Yak Master
118 Posts |
Posted - 2009-10-07 : 06:22:57
|
| Select clientidgroup byclientidhavingmax(date) < dateadd(M,-6,getdate()) |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2009-10-07 : 06:32:55
|
| [code]Select clientid from tblFoogroup by clientidhaving max(dateadd(day, datediff(day, 0, dateColumn), 0)) < dateadd(month, -6, dateadd(day, datediff(day, 0, getdate()), 0))[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|
|
|