SELECT
'Registered End Users' AS 'Report Name',
'Above Date Range' AS 'Desc',
CONVERT(VARCHAR, COUNT(*)) AS VALUE
FROM
WAPI_CUSTOMERS C
WHERE
C.ID NOT IN (SELECT S.CUSTOMER_ID FROM WAPI_SUBSCRIPTIONS S)
AND
CASE C.BASIC_REG_DATE IS NULL THEN C.FULL_REG_DATE BETWEEN @FROM_DATE AND @TO_DATE
WHEN C.FULL_REG_DATE IS NULL THEN C.BASIC_REG_DATE BETWEEN @FROM_DATE AND @TO_DATE
END
Actually I have two table named wapi_customers and wapi_subscribers. I have have get all rows of customer table which are not in subscriber table between user selected date range.
In customer table I have two types of customers like basic and full.
- basic customers have
isbasic=1andbasicregdate=somedateandisfull=0andfullregdate=null - full customers have
isbasic=0andbasicregdate=nullandisfull=1andfullregdate=somedate - case which are upgraded from basic to full:
isbasic=1andbasregdate=somedateandfullregdate=1andfulldate=somedate
Now I have to count customers which follow the above conditions means in case of basic
we will use C.BASIC_REG_DATE BETWEEN @FROM_DATE AND @TO_DATE and in case of full
C.FULL_REG_DATE BETWEEN @FROM_DATE AND @TO_DATE and in case of upgrade C.FULL_REG_DATE or C.BASIC_REG_DATE BETWEEN @FROM_DATE AND @TO_DATE
Plz help
If I understood you correctly, following is something would work for you: