This are the test classes related to the question in DC
Effective use of Collection Indexing and Querying Collections through SQL
Demo Server SMP
Demo Server WebTerminal
the repo is not so impressive, but the discussion in
Developer Community was a big help and explained
what is happening!