in reply to Sort label

I think you just want to modify your query to do the elimination:
SELECT id, num FROM index i1 WHERE id LIKE ? AND NOT EXISTS ( SELECT 1 FROM index WHERE id = 'G'||Substr(i1.id, 2) )
Index is a poor choice for a table name, by the way.

Caution: Contents may have been coded under pressure.