大神看看能不能实现

wnf2009 wnf2009 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我现在从数据库里查到的数据如下
A B C
------------
a b 5
a b @@
b c df
b c ss
c d @@
c d tt
现在就是想得到这样的结果:如果有A,B相同的组合,那么输出C为@@的那条。如果@@不存在,则输出本组的第一条
比如说上述数据就输出
a b @@
b c df
c d @@

公司里的代码格式比较固定,大神看看能不能实现。想在do-while里面全部实现?

String sql = "select * from ttt order by a,b,c";
// String sql = "select * from weather";
ResultSet rs = BaseDao.execQuery(sql);
String a = null;
String b = null;
String c = null;
boolean isLoop = true;
do {
if(rs.next()){
a = rs.getString("a");
b = rs.getString("b");
c = rs.getString("c");
}else{
isLoop = false;
rs.close();
}
} while (isLoop);
}
...全文
评论 3
收藏 已收藏
分享
返回顶部
wnf2009
Java SE 62,620 成员 307,251 内容