Focusing on SQL Table-value Functions. Something that will be similar to an Entity (to be used on Simple and Advance Queries) but the data is returned from an action or query.
Example1. When having hierarchies it's useful to centralize their structure in one query and then use it to join other tables, avoid cycles with 2,3 or 4 queries in each iteration.
Example2. When we have user info in n extended tables (USER, USER_EXT1, ...) we would like to return user info at once avoiding joining extended tables in each query that we have to make.