This formula can be extended for more than 3 tables to N tables, You just need to make sure that SQL query should have N-1 join statement in ...
stackoverflow.com