Is this a school task? We won't do your homework for you, but if you can show us what you have come up with so far, there will be plenty of people willing to help you further.
The fastest way to solve this kind of questions, is by gradually fine-tuning the query. Start with a query that is easy to write. Verify that the results are correct.
Once you have verified the correctness of the SQL query, you can start thinking of incorporating another part of the requirement. Take a copy of the previous query and make modifications on the copy. If you get struck, you can restart from the original query, that you have already proven to be correct.
Sometimes you may have to combine multiple queries to get the required result.
Quote:
|
1. Number of subscription started, no previous subscription for the same cstID
|
Possible steps
- write a query that calculates the number of records per cstID
- select only those cstID for whom the number of records is 1
- Select only those records where the current date falls between prsStartDate and prsEndDate.
- ...