求一sql语句(25)

  • 主题发起人 主题发起人 wlyft
  • 开始时间 开始时间
W

wlyft

Unregistered / Unconfirmed
GUEST, unregistred user!
表T2bbh zth bbh2 th x1 x2 x31 a 1 aa 7788 7788 77881 a 1 bb 7788 7788 77881 a 2 aa 7788 7788 77882 a 1 aa 7788 7788 77882 a 1 bb 7788 7788 77882 a 2 aa 7788 7788 77881 b 1 bb 7788 7788 77881 b 2 aa 7788 7788 77882 b 1 bb 7788 7788 77882 b 2 aa 7788 7788 77881 c 1 bb 7788 7788 77881 c 2 aa 7788 7788 77883 c 1 aa 7788 7788 77883 c 2 aa 7788 7788 7788select 如下结果bbh zth bbh2 th x1 x2 x32 a 2 aa 7788 7788 77882 b 2 aa 7788 7788 77883 c 2 aa 7788 7788 7788条件描述:bbh最大的所有zth中 的th='aa' bbh2最大的记录不知我这样表达清不清楚
 
没有试,大致写一个:select * from (select * from t2where zth+bbh in (select zth+max(bbh) from t2 group by zth)and th='aa' ) aawhere zth+max(bb2) in(select zth+max(bb2) from t2where zth+bbh in (select zth+max(bbh) from t2 group by zth)and th='aa' group by zth)
 
后退
顶部