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
Amit MohantyPosted Jan 4, 2024, 8:10 AM
If you're trying to retrieve the sum of RequestAmount for transactions within specific date ranges based on the current month, last month, last 3 months, and last 6 months then check the below queries.
Naimish MakwanaPosted Jan 4, 2024, 8:23 AM
It seems like you are trying to filter data based on the current month, last month, last 3 months, and last 6 months. The issue in your query is that you are only filtering based on the current month. To include data for the previous months, you need to adjust your date conditions.
Here's an example of how you can modify your query to achieve this:
Thanks
Satyaprakash SamantarayPosted Jan 4, 2024, 8:09 AM
can u try below query?