"select a.v_rec_id,a.v_title,(select count(*)from Answer as r where r.v_question_rec_id=a.v_rec_id) as val from Ask as a where a.v_flag='0' order by val desc";
09:14:32,781 ERROR JDBCExceptionReporter:78 - Unknown column 'val' in 'order clause'错误 这个要怎么办怎么办怎么办
------解决方案--------------------------------------------------------
你试试这样ok不
select a.v_rec_id,a.v_title,count(a.v_rec_id) val
from Ask a,Answer r
where r.v_question_rec_id=a.v_rec_id
and a.v_flag='0'
group by a.v_rec_id
order by val desc
------解决方案--------------------------------------------------------
select a.v_rec_id,
a.v_title,
count(a.v_rec_id) as val
from Ask as a
left join Answer as r
on r.v_question_rec_id = a.v_rec_id
where a.v_flag = '0'
group by a.v_rec_id,a.v_title
order by val desc