Build BOM in Query

Take a look at this thread.