Jaya Prakash

Jaya Prakash

  • 548
  • 2.3k
  • 63.3k

How to get this,monthlast month , last 3,last 6 amount data to display

Jan 4 2024 8:03 AM
 SELECT  Sum(RequestAmount)      
     from Transactions MT   
     INNER JOIN User_Heirarchy_Details UHD on MT.UserID=UHD.UserID       
     WHERE UHD.ParentUserID IN (select ParentUserID from User_Heirarchy_Details where UserID = 38 )     
     and Datepart(MM,MT.CreatedDate )=dATEPART(MM,getdate()) AND Datepart(YYYY,MT.CreatedDate )=dATEPART(YYYY,getdate())        
     and MT.[Status] in ('SUCCESS','PENDING')  

i can able to get data upto where userid=38
but when i try to filter with using datepart it is not giving any values but im having data related to date ranges pls help me to fix it


Answers (3)