余生Her 2014-06-18 06:50 采纳率: 0%
浏览 1688

sql语句问题求大神帮忙帮忙

select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number=1
select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number=2
select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number=3
select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number=4
select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number>=5
如何把这5条sql语句变成一条,我要的结果是 =1=2=3=4大于5的用户分别说多少,不是要总数的亲们

  • 写回答

2条回答 默认 最新

  • feiyun0112 2014-06-18 07:02
    关注

    select
    A=(select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number=1)
    ,B=(select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number=2)
    ,C=(select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number=3)
    ,D=(select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number=4)
    ,E=(select count(*) from (SELECT HY_GUID,COUNT(*) number FROM dbo.BI_GYDD GROUP BY HY_GUID) a where number>=5)

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制