SELECT category_id, category_name, main_category FROM test ORDER BY main_category, category_id