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 |
kond.mohan
Posting Yak Master
213 Posts |
Posted - 2012-04-11 : 08:14:04
|
I WANT TO FIND THE DATEDIFF B/W TO COLUMNONE OF COLUMN NEED TO FETCH THE MAX(ABC.DATE) COLUMN----DATEDIFF(DD,MAX(ABC.DATE),DFS.LCHG_TIME)STEP 2.I NEED TO CALCULATE COUNT OF THESE DAYS ---COUNT(DATEDIFF(DD,MAX(ABC.DATE),DFS.LCHG_TIME)) HAVING MAX(ABC.DATE)>DFS.LCHG_TIMESTEP3 COUNT(DATEDIFF(DD,MAX(ABC.DATE),DFS.LCHG_TIME)) BETWEEN 1 AND 5 SHOULD SHOW 1 COUMNCOUNT(DATEDIFF(DD,MAX(ABC.DATE),DFS.LCHG_TIME)) BETWEEN 6 AND 10SHOULD SHOW 1 COUMNCOUNT(DATEDIFF(DD,MAX(ABC.DATE),DFS.LCHG_TIME)) BETWEEN 11 AND 20SHOULD SHOW 1 COUMNFINAL EXPECTED STRUCTURE ISCOUNTOFDAYS 1-5 6-10 11-20 MORETHAN2010 3 1 2 420 4 10 3 350 5 15 15 15 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-12 : 00:52:27
|
can you post some sample data from table and explain what you want? thats much better than posting code partcurrently it sounds like what you need is pivot or cross tabbing------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|