select distinct u.Email_Address, u.Contact_Name, u.Phone_Number, 'ETT_BO_Clients_Not_filed_for_2022-23_MAR_20_2023' as [Filing Status] from ee_users u where u.Is_Deleted = 0 and u.User_Type_Id = 1 and u.Email_Address not like '%@spanenterprises.com%' and u.Email_Address not like '%@expressexcise.com%' and u.Email_Address not like '%@spanllc.com%' and u.Email_Address not like '%@w3magix.com%' and u.Email_Address not like '%@pdffiller.com%' and u.Email_Address not like '%@dotnetethics.com%' and u.Email_Address not like '%@expressefile.com%' and u.Email_Address not like '%@spantechnologyservices.com%' and U.USER_ID IN ( SELECT USER_ID FROM ee_Returns where u.Is_Deleted = 0 and Is_Paid = 1 ) --with having have returns and U.USER_ID NOT IN ( SELECT USER_ID FROM EE_USERS WHERE Affiliate_Id in (363, 387) ) --EEF,TRUCK Logic and u.USER_ID NOT IN ( SELECT USER_ID FROM EE_USERS WHERE ( Referral_code in('NASTC') ) ) and u.user_Id not in ( select useR_Id from ee_Group_Member_Details where is_deleted = 0 and group_Id in (7, 70, 71, 72, 10, 8, 9, 11, 5, 1, 28, 54, 57, 73))
select distinct u.Email_Address as [Email Address], u.contact_name as [First Name], u.Phone_Number, 'ETT_Clients_Business_Created_But_No_Returns_MAR_27_2023' as [Filing Status] from ee_Users u where exists ( select user_id from ee_BusinessDetails b where b.Is_Deleted = 0 and b.user_id = u.user_id ) and NOT exists( select user_id from ee_Returns r where r.Is_Deleted = 0 and r.user_id = u.user_id ) and u.Is_Deleted = 0 and u.Create_Time_Stamp >= '2022-06-01 00:00:00.000' and u.email_address not like '%@spanenterprises%' and u.email_address not like '%@spanllc%' and u.Email_Address not like '%@pdffiller.com%' and u.Email_Address not like '%@dotnetethics.com%' and u.Email_Address not like '%@spantechnologyservices.com%' and u.Email_Address not like '%@expressefile.com%' and u.email_address not like '%@expressexcise%' and u.email_address not like '%@w3magix%' and u.user_id not in ( select user_id from ee_group_member_details where group_id in (7, 70, 71, 72, 10, 8, 9, 11, 5, 1, 28, 54, 57, 73) )
select MONTH(r.Transmitted_Time_Stamp), count(1) as [Total Return Count] from ee_returns r where r.Filing_Status_Id in (4) and r.Transmitted_Time_Stamp >= '2022-01-01 00:00:00.000' and r.Transmitted_Time_Stamp < '2022-01-01 00:00:00.000' and r.Is_Deleted = 0 group by MONTH(r.Transmitted_Time_Stamp)
select MONTH(r.Transmitted_Time_Stamp), count(1) as [Total Return Count] from ee_returns r where r.Filing_Status_Id in (6) and r.Transmitted_Time_Stamp >= '2022-01-01 00:00:00.000' and r.Transmitted_Time_Stamp < '2022-01-01 00:00:00.000' and r.Is_Deleted = 0 group by MONTH(r.Transmitted_Time_Stamp)
( select count(distinct u.user_id) as [Return from New user] from ee_users u join ee_returns r on u.user_id = r.user_id where u.is_deleted = 0 and r.is_deleted = 0 and r.is_paid = 1 and u.create_time_stamp > @ExistDate and r.Transmitted_Time_Stamp >= @TransStartDate and r.Transmitted_Time_Stamp < @TransEndDate )
select count(r.Return_Id) as [Return from Existing user] from ee_users u join ee_returns r on u.user_id = r.user_id where u.is_deleted = 0 and r.is_deleted = 0 and r.is_paid = 1 and u.create_time_stamp < @ExistDate and r.Transmitted_Time_Stamp >= @TransStartDate and r.Transmitted_Time_Stamp < @TransEndDate
select count(distinct u.user_id) as [Return from New user] from ee_users u join ee_returns r on u.user_id = r.user_id where u.is_deleted = 0 and r.is_deleted = 0 and r.is_paid = 1 and u.create_time_stamp > @ExistDate and r.Transmitted_Time_Stamp >= @TransStartDate and r.Transmitted_Time_Stamp < @TransEndDate group BY day(r.Transmitted_Time_Stamp)
SELECT Aff.Referral_Code, Aff.Business_name, Aff.Phone_Number, Aff.Email_Address, Aff.create_time_stamp, ( SELECT COUNT(r.return_id) FROM ee_users u join ee_returns r on u.user_id = r.user_id WHERE r.filing_status_id > 2 and r.is_paid = 1 and r.create_time_stamp > '2022-05-16 00:00:00.000' and r.Update_Time_Stamp < '2023-03-07 00:00:00.000' and u.Referral_Code = Aff.Referral_Code and u.Is_Deleted = 0 and u.email_address not like '%spanenterprises%' and u.email_address not like '%spanllc%' and r.is_deleted = 0 and u.email_address not like '%expressexcise%' and u.email_address not like '%w3magix%' and u.Email_Address not like '%@spantechnologyservices.com' ) AS TOT_May_2023, ( SELECT COUNT(DISTINCT r.User_Id) FROM ee_users u join ee_returns r on u.user_id = r.user_id WHERE r.filing_status_id > 2 and r.is_paid = 1 and r.create_time_stamp > '2022-05-16 00:00:00.000' and r.Update_Time_Stamp < '2023-03-07 00:00:00.000' andu.Referral_Code = Aff.Referral_Code and u.Is_Deleted = 0 and u.email_address not like '%spanenterprises%' and u.email_address not like '%spanllc%' and r.is_deleted = 0 and u.email_address not like '%expressexcise%' and u.email_address not like '%w3magix%' and u.Email_Address not like '%@spantechnologyservices.com' ) as TOT_May_User_2023, ( SELECT COUNT(1) FROM ee_users WHERE ee_users.Referral_Code = Aff.Referral_Code and ee_Users.Is_Deleted = 0 and ee_users.email_address not like '%spanenterprises%' and ee_users.email_address not like '%spanllc%' and ee_users.email_address not like '%expressexcise%' and ee_users.email_address not like '%w3magix%' and ee_Users.Email_Address not like '%@spantechnologyservices.com' ) AS TOT_Users FROM ee_Affiliates as Aff where Aff.is_deleted = 0 and Affiliates_Type != 'Agency' and Affiliates_Type != 'Agent' and aff.is_active = 1 order by TOT_May_User_2023 desc