books = Books.objects.raw(
"""SELECT id, name FROM
(
SELECT DISTINCT NULL AS id, LEFT(name, 1) AS name FROM Books
UNION ALL
SELECT DISTINCT id, name FROM Books AS Books1
ORDER BY name
) AS t1
ORDER BY name""")
for book in books:
print(book.id)
print(book.name)