select id,subject,date,isnull(in_reply_to,id) AS irt from blog_comments WHERE blog_id = 1 ORDER BY irt, date;