TAuthor a = T_AUTHOR.as("a");
TBookStore s = T_BOOK_STORE.as("s");
TBookToBookStore t = T_BOOK_TO_BOOK_STORE.as("t");
Result<Record> result =
create.select(a.FIRST_NAME, a.LAST_NAME, countDistinct(s.NAME))
.from(a)
.join(b).on(b.AUTHOR_ID.equal(a.ID))
.join(t).on(t.BOOK_ID.equal(b.ID))
.join(s).on(t.BOOK_STORE_NAME.equal(s.NAME))
.groupBy(a.FIRST_NAME, a.LAST_NAME)