select m_id
from tbS
group by m_id
having max(state)='b'

解决方案 »

  1.   

    state 是不规则的字符串描述,不能max(state)的,只能根据s_id的大小来判断,我不能更改数据表的结构
      

  2.   

    insert * from tbs where s_id=(select max(s_id) from tbs where state='b')
      

  3.   

    insert tbs select * from tbs where s_id in (select max(s_id) from tbs where state in (select state from inserted) group by state)
      

  4.   

    select max(m_id)
    from tbS
    where state='b'