Sorting columns with aliases

Well, I found out that this can be achieved in 1 way. If I specify specific columns that I need instead of using * in my query, it will work.

Example:

SELECT st.student_id
FROM wp_o_students st
INNER JOIN wp_o_schools sc
ON st.school_id = sc.school_id
INNER JOIN wp_marks_list ml
ON st.student_id = ml.student_id
ORDER BY $orderby
LIMIT %d OFFSET %d

And for table columns:

'student_id' => __('Student ID', 'olympiad'),

Since there will be only 1 column with student_id, it will be used.