Have a look at
You can also use an approach like
and create flags for open and close dates in the link table. This additionally gives you the data to get the number of open cases (inbetween OPENED and CLOSED date).
edit: a sample for latter can be found in