1. che db usi (sai, il regolamento...)
2. se esegui SELECT MAX(id) FROM table WHERE y=1 cosa ottieni?