sql的一些问题

select distinct unitid,letterid from slj_nibanunit where nbstate=2
       group by unitid,letterid


比如这句话我可以拿到5条记录,那我怎么写这个sql拿到这个5?
FineReport回音无痕 发布于 2018-6-7 20:32
悬赏:2 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共8回答
最佳回答
0
axing发布于2018-6-7 20:32(编辑于 2023-9-6 09:34)
555
最佳回答
0
limbh发布于2018-6-7 20:42(编辑于 2023-9-6 09:34)
555
  • 回音无痕 回音无痕(提问者) ....................老哥这不行,哪有这么写的
    回复
    2018-06-07 21:10 
  • limbh limbh 回复 回音无痕 :MySQL数据库:select count(distinct unitid,letterid) from slj_nibanunit where nbstate=2
    oracle数据库:select count(distinct unitid||letterid) from slj_nibanunit where nbstate=2
    也不知道你是用哪个,不同数据库SQL语法也是有差别的。这两句都是测试过的,得出来结果会是5。
    要是你的需求不是这个那就把问题写的清楚些
    回复
    2018-06-07 22:01 
最佳回答
0
nationwoo发布于2018-6-7 21:53(编辑于 2023-9-6 09:34)
555
最佳回答
0
macro_hard发布于2018-6-7 22:13(编辑于 2023-9-6 09:34)
555
最佳回答
0
15616816979发布于2018-6-8 08:46(编辑于 2023-9-6 09:34)
555
最佳回答
0
axing发布于2018-6-8 08:58(编辑于 2023-9-6 09:34)
555
最佳回答
0
zy_20180110发布于2018-6-8 09:58(编辑于 2023-9-6 09:34)
555
最佳回答
0
No1-王子阳发布于2018-6-8 10:00(编辑于 2023-9-6 09:34)
555
  • 0关注人数
  • 750浏览人数
  • 最后回答于:2018-6-10 09:09
    活动推荐 更多
    热门课程 更多
    返回顶部